4

我有带有 clustergroup 的传单地图,它工作正常。我想在集群组单击时打开弹出窗口。在结束标记(元素)上,onclick 弹出窗口磨损良好。

我也能够捕获集群组单击事件,但无法打开弹出窗口。

    //To create cluster
          this.markers =  L.markerClusterGroup(); 

          //On cluster click get all children
          this.markers.on('clusterclick', function (a) {
             this.getClusterData(a.layer.getAllChildMarkers());
            //All children is available of cluster when clicked
        },this); 

但无法打开弹出窗口。

4

1 回答 1

4

我在这里找到了解决方案。可能会对其他人有所帮助。我浪费了一整天

cluster.on('clustermouseover', function(c) {
          var popup = L.popup()
              .setLatLng(c.layer.getLatLng())
              .setContent(c.layer._childCount +' Locations(click to Zoom)')
              .openOn(map);
          }).on('clustermouseout',function(c){
               map.closePopup();
          }).on('clusterclick',function(c){
               map.closePopup();
          });
于 2016-08-09T06:34:16.910 回答