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

Removing layers doesn't work with MarkerCluster #11

Closed
darthsteven opened this issue Mar 15, 2017 · 4 comments · Fixed by #12
Closed

Removing layers doesn't work with MarkerCluster #11

darthsteven opened this issue Mar 15, 2017 · 4 comments · Fixed by #12

Comments

@darthsteven
Copy link
Contributor

I have an application that needs to remove layers from the group, and have the parent group get updated.

This works fine if the parent group is, for example, the map or another layer group.

However, if the parent group is the markercluster then this doesn't work.

This is because the markercluster is expecting a fully loaded layer object to be passed to removeLayer, instead it's passed the ID of the layer, which fails to remove it as far as I can see.

@darthsteven
Copy link
Contributor Author

It does seem like the code should handle that case though, trying to work out what's up.

@darthsteven
Copy link
Contributor Author

Ah no, sorry, yeah, it always passes the numeric ID of the layer to remove, which isn't handled very well by markercluster.

@darthsteven
Copy link
Contributor Author

Not sure if I should suggest that MarkerCluster should support removal by ID rather than Layer object, but as the fix here is super easy, I'm going to fork and suggest the change.

@ghybs
Copy link
Owner

ghybs commented Mar 15, 2017

Hi,

Thank you for your report and for the PR!

Good catch about MCG not handling removeLayer(layerId).
Indeed an easy fix would be to retrieve back the full layer object before calling removeLayer, as done internally in Leaflet LayerGroup.

Looking at my code I see another inconsistency, hopefully I can fix that later on.
I will merge your PR in the meantime.

Thank you for your contribution!

@ghybs ghybs closed this as completed in #12 Mar 15, 2017
ghybs added a commit that referenced this issue Mar 15, 2017
…-markercluster

Remove layers by layer object, not id
ghybs added a commit that referenced this issue Mar 26, 2017
was calling  with layer's id only, whereas MCG does not handle the id but requires the layer object. See also issue #11 and PR #12.
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

Successfully merging a pull request may close this issue.

2 participants