Hi - the function below is called to create a set of markers on a map. My problem is that within the marker click listener I am trying to change the icon image. What is in fact happening is that the last marker to be added to the map ends up showing my 'special' icon as soon as it is drawn and the click event does not change the icon for any clicked marker. The 2 alerts show the problem - the first alert shows the correct marker id value onclick, the second alert always shows the id of the last marker added to the map and this is the marker that is given the 'special' image. So I guess my question is how to do get the setIcon method to act on the marker identified in the first alert.
Hope that makes a bit of sense to someone. Thanks for any help given as usual. function createMarker(markerData) { loc = new google.maps.LatLng(markerData.lat, markerData.lng); marker = new google.maps.Marker({ position: loc, map: map, icon: image, html: content, id: markerData.id }); google.maps.event.addListener(marker, 'click', function() { $("#markerDetail" + markerData.id).trigger("click"); $('#markerDetailCont').scrollTo("#markerDetail" + markerData.id, {speed:1000}); map.panTo(new google.maps.LatLng(markerData.lat, markerData.lng)); marker.setIcon('/images/site/marker_w.png'); alert(markerData.id); alert(marker.id); }); return marker; } -- 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 google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.