0

I have created a custom icon for clustering my data, using leaflet markercluster. As default markercluster have the "childcount" in the icon. How can i put that number in my divicon?

var markers = L.markerClusterGroup({
iconCreateFunction: function(cluster) {
    return L.divIcon({className: 'mydivicon', html: 'childcount'});
}
});

of course it just puts the text "childicon" in the circle. The child icon is a 'var' in the leaflet.markercluster-src.js

var childCount = cluster.getChildCount();

How can i write it in my L.divicon?

1

Okay i have the answer now:

var markers = L.markerClusterGroup({
iconCreateFunction: function(cluster) {
var childCount = cluster.getChildCount();
    return L.divIcon({className: 'mydivicon', html: '<div><span>' + childCount + '</span></div>'});
}
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.