【问题标题】:How can I customise marker clusters with ngx-leaflet.markercluster如何使用 ngx-leaflet.markercluster 自定义标记集群
【发布时间】:2020-04-24 03:58:42
【问题描述】:

我一直在尝试使用 ngx-leaflet 的自定义集群选项,但遇到了困难。现在我只想更改所有标记集群以显示单词“hello”,

演示 https://github.com/Asymmetrik/ngx-leaflet-markercluster/tree/master/src/demo/app 包含变量,但没有进一步说明,文档 https://github.com/Asymmetrik/ngx-leaflet-markercluster#leafletmarkerclusteroptions 指向传单自己的文档。

据我所知,我应该这样做:

markercluster-demo.component.ts

markerClusterGroup: L.MarkerClusterGroup;
markerClusterData: L.Marker[] = [];
markerClusterOptions = L.markerClusterGroup({
    iconCreateFunction(cluster) {
      return L.divIcon({ html: '<b>hello</b>' });
    }
});

谁有它工作的例子?

谢谢

【问题讨论】:

    标签: angular typescript leaflet ngx-leaflet


    【解决方案1】:

    想通了

        public markerClusterOptions: L.MarkerClusterGroupOptions = {
        iconCreateFunction() {
            const icon = L.divIcon({
                iconSize: [35, 35],
                iconAnchor: [10, 10],
                popupAnchor: [10, 0],
                shadowSize: [0, 0],
                html: '<div>Hello</div>'
            });
            return icon;
        }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多