angulartypescriptleafletngx-leaflet

How can I customise marker clusters with ngx-leaflet.markercluster


I've been trying use ngx-leaflet's custom cluster options but have hit a wall. For now I just want to change all marker clusters to display the word "hello",

The demo https://github.com/Asymmetrik/ngx-leaflet-markercluster/tree/master/src/demo/app contains variable but doesn't go any further and the docs https://github.com/Asymmetrik/ngx-leaflet-markercluster#leafletmarkerclusteroptions point towards leaflets own documentation.

From what I can gather I should be doing something like this:

markercluster-demo.component.ts

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

Anyone have any examples of it working?

Thanks


Solution

  • Figured it out

        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;
        }
    };