问题
I want to get a new map not using refush the webpage.
thanks
and has easy way to get all Overlays on the map?
回答1:
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.
回答2:
Look the google map api documentation
And in particular: clearOverlays()
回答3:
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;
}
来源:https://stackoverflow.com/questions/3248373/any-simple-way-to-clean-all-markers-polylines-and-other-overlays-on-google-maps