2

In Leaflet, I am using the markercluster plugin, in which you can use the DivIcon class to display custom icons for the clusters. You can set your own HTML for these clusters. However, I can't find how to update the HTML of an existing cluster icon. How can I do this?

1 Answer 1

3

you can use setIcon like that

var img2 = "<img src='image.jpg' />";
var icon2 = L.divIcon({
        html: img2,
        // Specify a class name we can refer to in CSS.
        className: 'image-icon',
        // Set a markers width and height.
        iconSize: [52, 52]
        });


marker.setIcon(icon2);

Look at this JSFiddle

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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