Leaflet / Leaflet.markercluster

Marker Clustering plugin for Leaflet
MIT License
3.98k stars 1k forks source link

Change cluster color when clicked #1085

Open FedericoChavazza opened 1 year ago

FedericoChavazza commented 1 year ago

How to reproduce

I've been having some trouble lately trying to implement a className change when clicking a specific cluster (all I wanna do is to change the color of the cluster once is clicked). The reason why this happens is because the class itself does not persist, it changes on every cluster render. I tried to change the className manually by using the "clusterclick" event (did not work), and using the iconCreateFunction too (did not work either) because there is no way to see if that cluster was clicked or not. For some reason, zooming in or zooming out changes the leaflet_id too, so idk what to dooo :,(

image

the change class idea

image

What behaviour I'm expecting and which behaviour I'm seeing

the cluster to change color once is clicked

Minimal example reproducing the issue

Using http://leafletjs.com/edit.html or any other jsfiddle-like site.