GMaps v3 Markers AddListener Problem
I am trying to add a mouseover / mouseout event listener to my markers, but I always get the last value of the for loop. In all events, it seems that the latter value is for instead of the current one. Here is my code
for( mark in data ) {
markers[mark] = new google.maps.Marker({
position: new google.maps.LatLng(data[mark].lat,data[mark].lng), map: map,
});
google.maps.event.addListener(markers[mark], "mouseover", function() {
alert(mark);
});
google.maps.event.addListener(markers[mark], "mouseout", function() {
alert(mark);
});
}
The result is a mouse transition / mouseout warning with the same value for all 10 markers, and I expected the marker identifier in each warning.
Thanks Relations
source
share