Hello - I have a map (v3) that loads a series of markers, each with an
associated onclick event handler and infowindow.
Currently, the location of all the markers, the type of the marker,
and the infowindow content is all set at page load.
I have been attempting to modify this so that an ajax call (using
prototype) can do this update periodically.
When initially creating my markers, I put each into a global array so
that I can refer to them later:
markerArray[id] = new google.maps.Marker({.....});
Where id is a reference to the marker.
When the ajax call completes, I check the newly received data to see
if the marker needs changing. If it does, I call:
markerArray[id].setImage(testicon);
I have put in an alert above this line, and I reach this point when I
should, but the marker on the map does not change. Is it possible to
dynamically update marker icons like this?
I also try to change the infowindow associated with that marker by
calling:
google.maps.event.addListener(markerArray[id], 'click', function() {
if (!infowindow) {
infowindow = new google.maps.InfoWindow();
infowindow.setContent(str);
infowindow.open(map,marker);
} else {
infowindow.setContent(str);
infowindow.open(map,marker);
}
I'm not sure if I should store all the events in a global array like
the markers, so that I can remove them and replace them as they need
updating? Anyway - I tried both of the above sections in isolation and
am not getting very far with either of them, so any help would be much
appreciated!
Cheers,
Ben
--
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.