我一直在尝试使用 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>' });
}
});
有人有它工作的例子吗?
谢谢
最佳答案
想通了
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;
}
};
关于angular - 如何使用 ngx-leaflet.markercluster 自定义标记簇,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61400905/