Search code examples
javascriptleafletleaflet.markercluster

How to set options of each cluster in MarkerClusterGroup


I create my own MarkerClusterGroup with the following way:

this.cluster = leaflet.markerClusterGroup({
    zoomToBoundsOnClick: false,
    showCoverageOnHover: false,
    spiderfyDistanceMultiplier: 3,
    spiderLegPolylineOptions: {
        weight: 1.5,
        color: "#1BA5D0",
        lineCap: "butt",
        dashArray: "10 10",
        opacity: 0.5
    }
});

How can I apply some options for each cluster (as far as it actually leaflet.Marker) inside that group? Especially, I would like to set riseOnHover: true

I found out that there is some way with controlling whole MarkerClusterGroup positioning with custom panes but this is not my case


Solution

  • Finally, I figured it out. Options could be set inside iconCreateFunction:

    this.cluster = leaflet.markerClusterGroup({
        iconCreateFunction: cluster => {
            cluster.options.riseOnHover = true;
        }
    });