I have a marker array that needs to be re-set after I load a new map.  I 
also want to be able to double-click markers to erase them.  Simplified code 
looks like:

for(i=0;i<allPins.length;i++){if(allPins[i]!=null){
    allPins[i].setMap(griddedMap);
    google.maps.event.addListener(allPins[i], 'dblclick', function(obj) {
        allPins[i].setMap(null);
        allPins[i] = null;
    });
}};

When I double-click a marker, it is kind of random what happens.  Sometimes 
the map zooms, indicating no listener.  Sometimes more than one marker will 
disappear.  Sometimes it works.  Very strange.

I think the problem is the two references to allPins[i] inside the listener 
function are getting evaluated at run time with some random value of i.  
What I really am trying to refer to is the marker that is being clicked, 
passed to the listener from the array: allPins[i].  Said another way, I need 
something lilke:

markerbeingclicked.setMap(null);
markerbeingclicked = null;

but I don't think that's what I am getting when I use allPins[i].  Any 
suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to