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