关闭Google Maps API中的聚合功能

6
我正在创建地图上的聚类,就像这样:
markerCluster = new MarkerClusterer(map, markers, mcOptions);

在不刷新地图标记的情况下,是否可以暂时关闭聚类,然后再次启用聚类?

2个回答

4

你可以尝试将maxZoom和gridSize设置为最小值。

markerClusterer.setMaxZoom(1);
markerClusterer.setGridSize(1);
markerClusterer.redraw();

在这之前,你可以先保存之前的值(getMaxZoom() 和 getGridSize())。根据参考文档,并没有像 enableClustering() 这样的函数。


1
嗨,谢谢你的回答 - 我实际上在这里找到了一个很好的例子:http://www.geocodezip.com/v3_GoogleEx_markerclusterer_unclusterB.html - gp.

3

这个repaint()方法适用于我:

    var markerCluster2 = new MarkerClusterer(map, markers, mcOptions);

$('#turnoff_clustering').click(function(){
                markerCluster2.setMaxZoom(1);
                markerCluster2.repaint();
});

需要注意的是,在上面的示例中,必须使用MarkerClustererPlus,因为MarkerClusterer没有.repaint()方法。 - danagerous

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接