I have a page that displays a map with several markers (say 10) using the Yahoo
AJAX API. Every once in a while (say once an hour), I want to change the status
of the markers (i.e. change the icon and text) based on input from a JSON data
source.
Currently, the web page draws all the markers nicely, but when I later try to
change the markers, I run into 2 issues:
1) "map.removeMarkersAll();" does not seem to remove any of the existing markers
2) when I try to put new markers up, they always appear stacked up in the upper
left corner of the map (no matter what zoom level or map position).
I am drawing the markers with something like:
var myImage = new YImage();
myImage.src = 'img/MapIcons/point_1.png';
myImage.size = new YSize(48,48);
myImage.offsetSmartWindow = new YCoordPoint(24, 0);
var msg = 'some message';
var newMarker= new YMarker(new YGeoPoint(lat, lng), myImage);
newMarker.addAutoExpand( msg);
var markerMarkup = msg;
YEvent.Capture(newMarker, EventsList.MouseClick,
function(){
newMarker.openSmartWindow(markerMarkup);
});
map.addOverlay(newMarker);
Does anyone have any ideas on a good way to refresh the markers?
Thanks,
Mark Bentley