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

Problems for ClearLayers and addLayers method #99

Closed
apuntovanini opened this issue Dec 3, 2012 · 8 comments
Closed

Problems for ClearLayers and addLayers method #99

apuntovanini opened this issue Dec 3, 2012 · 8 comments

Comments

@apuntovanini
Copy link

Hi!

I think there's an issue when trying to clear layers and add layers. Basically, I have a map in which i cluster 4 different layer groups. I set a little filter that hides and shows groups accordingly:

$(document).on("click", "#filters > li", function() {
markers.clearLayers();
switch ($(this).data('entity')) {
case 'Ngo':
markers.addLayer(ngos_markers);
break;
case 'User':
markers.addLayer(users_markers);
}
map.addLayer(markers);
});

The first time I click on the filters, markers do clear, and the new layer group is shown. When I try to do so second time, however, no markers are shown. I'm probably missing out something.
Can you help me out?

Thanks in advance!
Andrea

@danzel
Copy link
Member

danzel commented Dec 3, 2012

Do you end up calling map.addLayers(markers) multiple times? That might cause some issues.
That type of object is ngos_markers/users_markers. Are they arrays of markers?

Pretty certain I fixed all the issues with this, but there might be some left.

@apuntovanini
Copy link
Author

Yes, ngos_markers and users_markers are layer groups.
I also tried to remove the map.addLayer call on each click, but same results.

What's weird is that filter works just the first time and stops working for the next triggers.
Thanks again, amazing work

@apuntovanini
Copy link
Author

No news on this by chance?
Sorry to bother

@danzel
Copy link
Member

danzel commented Dec 5, 2012

Could you make a jsfiddle that reproduces the issue?
Otherwise I'll be taking a blind fiddle.
Will take a look a bit later today in either case.

@apuntovanini
Copy link
Author

I've been trying to reproduce the issue, but leaflet seems to have problems working in the jsfiddle iframe http://jsfiddle.net/apuntovanini/FKdfK/4/
Anyway, you can also check it live on our staging url http://uidue.sdconsult.in/map#11/45.6472/9.8266, clicking one of the icon filters available on the right.
Thanks again, really

@danzel
Copy link
Member

danzel commented Dec 5, 2012

You missed the css file:
http://jsfiddle.net/FKdfK/5/

Will take a look after lunch.

@danzel danzel closed this as completed in e86afca Dec 6, 2012
@danzel
Copy link
Member

danzel commented Dec 6, 2012

Yep, clearLayers wasn't quite doing the right thing. Fixed!

Check it out :)

@apuntovanini
Copy link
Author

Confirmed: it does work like a charm!
Thank you very much!!

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