-
Notifications
You must be signed in to change notification settings - Fork 505
Auto show/hide legend using layer control #400
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
Conversation
Is this supposed to hide a legend when I toggle the layer control on the right? I ran the function and the example and the legend remains on the map. |
Could you upload it on round for me to look at? |
All I did was run the R/legend.R script from the files changed tab then I ran the inst/examples/legend.R file. The maps with the circle markers pops up but when I toggle the 'circles' group, the legend on the bottom left remains. |
It does work for me, both layer and legend are toggled with the layer control. Sweet!! Looking forward to have this in master |
@jakeeander you need to properly install the package, not just source the R files. Before running the example do |
Oops sorry you need to install this PR and not the master as this hasn't been merged yet. |
@jcheng5 Could you review and merge this if OK ? |
I used this PR and it worked. Much appreciated! Great work. This is just supposed to work with the overlayGroups parameter and not the baseGroups parameter correct? |
For now overlay groups only, I figured base groups are for base maps, but it's not too hard to add the functionality for base map changes too if required. |
That would be a great addition for me. I've made some maps where the baseGroups parameter switches based on different addPolygons set of data. That works well and then an overlayGroups parameter would be set to locations using addCircles or addMarkers. |
OK I will add that feature |
any update on merging this? I would really appreciate this feature! |
@bhaskarvk Seems like it should respect |
Good point. Unfortunately I have no free time for the foreseeable future to work on this. I think I can get back to this my mid may, but probably not before that. |
Actually on second thought, my PR will work correctly with |
It doesn't, I think because the event only fires when the control is used. But we could fire a similar event from the show/hide methods, that'd be a cheap but still sorta general fix. |
Sorry for the basic question, but would someone please let me know how I can add this update to my version of leaflet? Thanks! |
I should be able to work on this next week. |
@bhaskarvk Thanks so much! |
Working on a new PR based of master. Closing this. |
Glad to hear! When do you think this will be ready, please? @bhaskarvk |
Hoping to work on this over the weekend. |
Hi @bhaskarvk - did you get the chance to work on this? Thanks! |
New PR #442. |
Auto show/hide legend based on a overlay group.
A lot of people have asked for this feature, where the legend should auto show/hide based on toggling an overlay group. I've modified the example to show how it works.