我使用谷歌地图API V3。

我迁移我的网站GMAP API V2 - > V3。  但应对因为我使用了提供clearOverlays()方法在曾经在V2来删除现有的对象,并且它在删除了什么在V3被废除的对象单独

<强> V2

map.clearOverlays();

<强> V3

map.set_visible(false);
popup.close();

是它OK? 或其它溶液?

其他提示

下面是我做的:

创建一个空数组文本,按下标记为你让他们,并在必要时然后驱逐他们

var eviction_list = [];

function evictMarkers() {

    // clear all markers

    $(eviction_list).each(function () {
         this.set_map(null);
    });

    // reset the eviction array 
    eviction_list = [];
}

//in function adding markers
......
marker = new google.maps.Marker({
    position: results[0].geometry.location,
    map: map,
    title: elem.title
});
eviction_list.push(marker);
......

//to clear all markers
evictMarkers();

作为宏伟正确提到,被调用的函数的setMap(),不set_map()。

请参阅 http://code.google.com/的API /地图/文档/ V3 / overlays.html#隐藏显示

问题是,setMap(null)可能会很慢,当你有很多的标记。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top