【问题标题】:Marker Clusterer Plus remove cluster on clickMarker Clusterer Plus 单击时删除集群
【发布时间】:2015-01-24 18:44:18
【问题描述】:

我正在使用这个工具

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/

用于精确定位或非常接近的聚类标记 (gridSize: 5)

我想要做的是在点击时删除一个集群(不是全部,只是一个)并使用蜘蛛标记

https://github.com/jawj/OverlappingMarkerSpiderfier

这个可以吗?

在参考 Marker clusterer 时,我没有找到任何删除特定集群的函数/方法。

提前致谢。

【问题讨论】:

    标签: javascript google-maps-api-3 markerclusterer markerspiderfier


    【解决方案1】:

    我会使用我自己的 MarkerClustererPlus 版本并稍作修改:

    //@150 of MarkerClustererPlus: modify to send cClusterIcon.div_ on the click event
    google.maps.event.trigger(mc, "click", cClusterIcon.cluster_, cClusterIcon.div_);
    

    在你的代码中这样使用它:

    google.maps.event.addListener(markerCluster, 'click', function (cluster, clusterIcon) {
        clusterIcon.remove();
        //Do the other stuff with the markers ...
        var markers = cluster.getMarkers();
    });
    

    【讨论】:

    • 在 MarkerClustererPlus 的第 150 行附近
    • 抱歉,找到了,我在找错文件(MarkerClusterer,不是 MarkerClustererPlus)。我现在就试试。
    • 好的,这可行(删除/隐藏图标),但是如何显示 / 聚集的标记
    • cluster.getMarkers();
    • 使用 cluster.getMarkers(),我从该集群中获取标记,但它们没有显示在地图上,我无法在它们上触发点击事件(这会触发 spiderfy)。
    猜你喜欢
    • 1970-01-01
    • 2013-12-25
    • 2020-11-07
    • 1970-01-01
    • 2012-07-02
    • 2015-07-25
    • 2013-12-31
    • 1970-01-01
    • 2015-05-07
    相关资源
    最近更新 更多