In Google Maps API v2, I was using map.clearOverlays()
to remove the marker and draw them again.
How can I do that using Google Maps API v3 ?
Th
This is good one:
http://apitricks.blogspot.com/2010/02/clearoverlays-in-v3.html
Article in case the link dies:
clearOverlays() in V3
There is no clearOverlays() in API v3. Some practices have been presented. I think this is the simpliest so far.
Push all the overlays in an array when created (as usual). Following code will clear both map and the array:
while(overlays[0])
{
overlays.pop().setMap(null);
}
pop() method of an array removes the last element of an array, and returns that element. 'while' keeps that happening as long as there are elements in the array. When overlays[0] does not exist anymore, the mission is completed and code will proceed.