On Mar 15, 1:04 am, Kareb <[email protected]> wrote: > Hi, > > I am using .setImage to change the image for a marker. Howevere it is > changing the image for the wrong marker. > > I have set up a simplified example > athttp://www.homeforhire.com/googlemaptest.aspx
It works for me, but the problem is the asynchronous nature of geocoding. You are geocoding four addresses, and you have no control over which one finishes first. So you could end up creating the marker with markerIndex 1 before marker zero. However, you are simply pushing markers on to the markers[] array in the order in which they are created. In this case what you want to be marker 1 will be in position zero in the array. A fix would be to replace markers.push(marker); with markers[markerIndex] = marker; as that would tie the marker to the index number you have given it. -- You received this message because you are subscribed to the Google Groups "Google Maps API" 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-api?hl=en.
