有什么简单的方法可以清除Google Maps v3 API上的所有标记,折线和其他叠加层?

问题描述:

我想获取不使用刷新网页的新地图.

I want to get a new map not using refush the webpage.

谢谢

有简单的方法在地图上获取所有叠加层吗?

and has easy way to get all Overlays on the map?

在v2 API中,存在 Gaby指出了.但是,如果使用v3 API,则不存在此方法.如果我没记错的话,这种遗漏是为了使库保持轻量级.

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.

因此,使用v3 API,您必须保留叠加层的引用,然后在每个叠加层上调用setMap(null).

Therefore, with the v3 API, you have to keep a reference of your overlays, and then call setMap(null) on each overlay.