谷歌地图API V3 - 如何清除覆盖? [英] Google Maps API v3 - How to clear overlays?

查看:583
本文介绍了谷歌地图API V3 - 如何清除覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌地图API第2版,我是用 map.clearOverlays()删除标记,并再次吸引他们。

In Google Maps API v2, I was using map.clearOverlays() to remove the marker and draw them again.

我怎么能做到这一点使用谷歌地图API V3?

How can I do that using Google Maps API v3 ?

感谢

推荐答案

请参阅here有关各种选项的详细信息打开你,但你现在可以通过标记进行迭代,并逐个删除它们。您code应该是这个样子:

See here for details on the various options open to you but you now have to iterate through the markers and remove them individually. Your code should look something like this:

var markers = [];

function clearOverlays() {
 while(markers.length) { markers.pop().setMap(null); }
  markers.length = 0;
}

markers.push(marker);
google.maps.event.addListener(marker,"click",function(){});

这篇关于谷歌地图API V3 - 如何清除覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆