I want to get a new map not using refush the webpage.
thanks
and has easy way to get all Overlays on the map?
I want to get a new map not using refush the webpage.
thanks
and has easy way to get all Overlays on the map?
In the v2 API, there was the clearOverlays()
method as Gaby pointed out. However, this method is not present if the v3 API. If I remember correctly, this omission was intentional to keep the library lightweight.
Therefore, with the v3 API, you have to keep a reference of your overlays, and then call setMap(null)
on each overlay.
FYI for peoples using V3: From what I have found, V3 does not have a packaged function like V2 does in .clearOverlays();
Here is what I do (as I've gathered from other resources):
var gmarkers = []; // establish your markers array;
if (gmarkers) { // plug this in wherever/whenever you want to clear the map of any and all markers;
for (i in gmarkers) {
gmarkers[i].setMap(null);
}
gmarkers.length = 0;
}
Look the google map api documentation
And in particular: clearOverlays()