Google Maps Api v3-如何删除群集图标? [英] Google Maps Api v3 - how to remove cluster icons?

查看:92
本文介绍了Google Maps Api v3-如何删除群集图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从地图上删除所有群集图标(群集标记)?尝试了以下建议:

how can i remove all cluster icons (cluster markers) from map? tryed with advices like:

Google Maps API v3:如何删除所有标记?

...但是没有用.

您能帮我实现这一目标吗?

can you help me how to achieve that?

先谢谢您!

更新(2010-11-23)

标记与

var markersClust = Array();

...并与(与php组合)一起添加:

... and are added with (combination with php):

markersClust.push(marker_<?php echo $team["Team"]["id"]; ?>);

var markerClusterer = new MarkerClusterer(MyMap.map, markersClust, clusterOptions);

它工作正常.

但是,我无法将它们从地图上删除,这驱使我...

but, i can not remove them from a map, and it drives me...

试图删除标记(我这样做了)

tryed to remove markers (and i did) with

for ( var i=0; i < markersClust.length; i++) {
    markersClust[i].setMap(null);
}
markersClust = []; 

但是群集图标在地图上仍然显示.

but cluster icons are stil on the map.

我也尝试过类似的事情:

also i tryed things like:

markerClusterer.clearMarkers();

喜欢

MyMap.preventDefault();
MyMap.stopPropagation();
MyMap.clearMarkers();

但是,在地图上,集群的图标仍然存在.

but, again, icons of the clusters are still there, on a map.

从地图上删除那些群集图标,我还需要做什么?请帮忙...

what else do i have to do to remove those cluster icons from my map? please help...

推荐答案

遍历每个标记并将该标记的映射设置为null.这样会将标记从地图上删除.

Iterate over each marker and set that marker's map to null. That will remove the marker from the map.

这篇关于Google Maps Api v3-如何删除群集图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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