-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
clearLayers() doesn't always work on geojson layergroups #1512
Comments
Hey there - sounds like the issue I've been running into with FeatureGroup events in #1495. It's related to the way Leaflet.Events is indexing listeners in the current master - it's not breaking in your jsfiddle because you're pointed at the last release, 0.5.1, not at master. I've not really dug into the problem too deep yet - though it seems like ensuring your group has a _leaflet_id by calling L.stamp() on it will at least keep events from throwing that error.
|
Thanks guys, will take a look at this and #1495 soon. |
@brianherbert Check out #1514 for a fix. |
I think this should be closed, fixed AFAIK. |
It is still not working for me. |
I realize I was not on HEAD. |
I'm having a hard time reproducing an issue I'm having when I clearLayers() on a geojson layer group. I create a layer group like so:
Then later, I want to refresh the layer by removing it's contents and repopulating it:
However, when clearLayers executes, I'm seeing an error saying that an event doesn't exist.
I changed line 405 https://github.com/Leaflet/Leaflet/blob/master/dist/leaflet-src.js#L405 to check and make sire it exists before attempting to delete it, like so:
This fixes my issue, but I cannot figure out why it's doing this. Any pointers would be great since I don't want to mess with the core library or submit a pull request if I don't know what's wrong.
I created this simple jsfiddle, which works (much to my frustration): http://jsfiddle.net/3Sqvq/5/
The text was updated successfully, but these errors were encountered: