【问题标题】:Turn off clustering with Google Maps API使用 Google Maps API 关闭集群
【发布时间】:2011-12-16 01:28:10
【问题描述】:

我正在像这样在地图上创建集群:

markerCluster = new MarkerClusterer(map, markers, mcOptions);

在不“刷新”地图标记的情况下,是否可以暂时关闭聚类,然后再重新打开?

【问题讨论】:

    标签: google-maps


    【解决方案1】:

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

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

    在此之前,您可以只保存以前的值(getMaxZoom() 和 getGridSize())。依靠reference,没有什么能比得上 enableClustering()。

    【讨论】:

    【解决方案2】:

    这个repaint() 方法对我有用:

        var markerCluster2 = new MarkerClusterer(map, markers, mcOptions);
    
    $('#turnoff_clustering').click(function(){
                    markerCluster2.setMaxZoom(1);
                    markerCluster2.repaint();
    });
    

    【讨论】:

    • 需要注意的是上例中必须使用MarkerClustererPlus,因为MarkerClusterer没有.repaint()方法。
    猜你喜欢
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 2011-05-23
    • 2011-11-23
    • 2014-02-18
    • 2011-05-14
    相关资源
    最近更新 更多