Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon color while being clustered #561

Closed
emakarov opened this issue Oct 1, 2015 · 3 comments
Closed

Icon color while being clustered #561

emakarov opened this issue Oct 1, 2015 · 3 comments

Comments

@emakarov
Copy link

emakarov commented Oct 1, 2015

In my project, color of icon is changing dynamically.
And we have such bug -
Icon is yellow, we zoom out, icons are clustered.
Icon that was yellow becomes red
But when we zoom in, it still becomes yellow.
So cluster somehow remember "old marker icon" state and shows it instead of new
Color is actually background color of html (icon is htmldiv).
So basically, icon keeps old html

ghybs added a commit to ghybs/Leaflet.markercluster that referenced this issue Oct 1, 2015
@danzel
Copy link
Member

danzel commented Oct 2, 2015

How are you changing the color of the icon?

@emakarov
Copy link
Author

emakarov commented Oct 2, 2015

we used direct DOM html change of each icon and I think maybe this is the issue.
Investigation shown that when markers aggregated into a cluster, DOM elements of icon are removed.
I will try to change the logic using leaflet methods. Is there anything to add from your side?

@danzel
Copy link
Member

danzel commented Oct 2, 2015

You are on to it.
When markers are merged in to clusters and expanded out from clusters they are removed and added to the map.
When this happens leaflet will remove and re-create their icon from their icon object, losing any custom html changes.

If you change the icon instead - use setHTML or setClass on the icon (I think they are methods?) then everything should work correctly.

@danzel danzel closed this as completed Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants