"鬼"使用angular-leaflet-directive自定义markercluster图标时的集群

时间:2014-12-16 08:43:45

标签: angularjs angularjs-directive leaflet markerclusterer angular-leaflet-directive

我尝试使用以下代码自定义angular-leaflet markerclusters:

            overlays: {
                defaultOverlay: {
                    type: 'markercluster',
                    name: 'defaultOverlay',
                    visible: true,
                    layerOptions: {
                        showCoverageOnHover: true,
                        disableClusteringAtZoom: 15,
                        iconCreateFunction: customMarkerCluster
                    }
                }
            }

我有7个标记的测试样本,定义如下:

                markers: [
                    {
                        _id: "548f0ab268dc96e7587c0f8f",
                        layer:"defaultOverlay",
                        group: "testgroup1",
                        lat: 20.973368,
                        lng: 40.849463,
                        title: "IMPERIUM",
                        message: "215 Rockaway Parkway, Delshire, Ohio, 9191",
                        icon: $scope.icons.onlineNotifIcon,
                        status: 1
                    },
                    ...
                ]

如果我隐藏了可见的覆盖:false或者不使用覆盖,我会获得正确数量的标记,但永远不会调用customMarkerCluster。

使用visible:true,我得到3个4个标记的簇(12个标记而不是7个)

如何在使用叠加层时阻止markercluster生成错误的群集?

1 个答案:

答案 0 :(得分:1)

显然,我的选项组正在搞乱markercluster生成,我删除了组,一切正常(+清理了我的例子)

                    {
                        "_id": "548f0ab268dc96e7587c0f8f",
                        layer:"defaultOverlay",
                        lat: 28.239855,
                        lng: 14.752357,
                        title: "BITTOR",
                        message: "856 Furman Avenue, Comptche, Nebraska, 3995",
                        icon: $scope.icons.onlineIcon,
                        status: 0

                    }