Google Maps API v3 - How to clear overlays?

前端 未结 7 2258
野性不改
野性不改 2020-12-31 00:30

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

7条回答
  •  灰色年华
    2020-12-31 00:59

    The overlayMapTypes object brings a clear method:

    map.overlayMapTypes.clear()

    Whereas map is your Google Maps object.

    If you cannot find the method in your API version, you can resort to the following source of clear:

    clear = function() {
        for (; this.get("length");) this.pop()
    };
    

提交回复
热议问题