I have been using Yahoomap API for quite sometime. There are some annoying bugs which gave me a tough time.
Some of the bugs related to the marker manager are:
1. _yahooMap.markerManager.markers.splice(1,1);
does nothing. Even though the markers is an array and should allow the Splice operation to go through but nothing happens
2. _yahooMap.markerManager.removeAllMarkers()
gives an annoying error.""Error# 1009: Cannot access a property or method of a null object reference"
3. _yahooMap.markerManager.removeMarker(obj as Marker) is also buggy.
The intended behavior its that it should just remove the particular marker that is passed in the call, instead it removes all the markers that are present after the specified marker. So assuming if the markers array is [1,2,3,4] where the numbers are the marker ids. The call _yahooMap.markerManager.removeMarker(2) will give [1] instead of [1,3,4]
4. _yahooMap.markerManager.pop(): doesnot remove the element from the markers array it just gives the reference to it. So even after the pop() operation the marker manager will contain the recent most marker.
Solution for removing the markers from the marker manager
I have used the a work around for removing the items from the marker manager. I exploited the current behavior(buggy one see point 3) of _yahooMap.markerManager.removeMarker(obj as Marker).
The function is removing all the elements that are present after the marker passed in the call. So I am passing the recent most marker so that it removes latest marker and the markers after that (which will be null). Let me give one example
say the marker manager contains markers #: 1,2,3,4
we will use the following code to remove the markers. so after every pass we get
pass 1: 1,2,3 (4 is removed and there was nothing after that so only 4)
pass 2: 1,2
pass 3: 1
pass 4: null
private function removeYahooMarkers():void
{
var len:int=_yahooMap.markerManager.markers.length;
for(var i:int=0;i<len;i++)
{
var obj:Object= _yahooMap.markerManager.markers.pop();
if(obj!=null)
_yahooMap.markerManager.removeMarker(obj as Marker)
if(obj==null)
return;
}
}
Even the overlayManager is buggy.
There is some refresh problem. In case of removing any overlay, the overlay manager does not refreshes the overlays array.
So if you do
_yahooMap.overlayManager.removeAllOverlays(); it would have removed the overlays internally but the overlays array still contains the references (something like dangling pointers in C/C++)
one workaround is to just call the removeAllOverlays(0 again so
_yahooMap.overlayManager.removeAllOverlays();
_yahooMap.overlayManager.removeAllOverlays();