I need a Google Maps Marker to respond to an event triggered by the Map (idle). The event triggers a function. This function is SUPPOSED to act on the Marker, but of course, “this” refers to the map. How, inside the function, can I reference the Marker that set the event listener.
Every Marker will add an idle listener to the map. I could track all the markers, and upon a Map Idle Event, loop through them and trigger the function, but I was hoping on a more zen method.
My current method is this:
var self=newMarker;
google.maps.event.addListener(window.gmap,'idle',function(){
self.setVisible(false); });
But it only seems to work for 1 marker. “newMarker” is the marker object I’m trying to access from inside the event, and as I said there’s multiple markers, so I can’t just store it in a global variable or anything.
Use jQuery’s “proxy”, jQuery Proxy