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

add group arg to addControl function #647

Open
PaulC91 opened this issue Oct 13, 2019 · 2 comments
Open

add group arg to addControl function #647

PaulC91 opened this issue Oct 13, 2019 · 2 comments

Comments

@PaulC91
Copy link

PaulC91 commented Oct 13, 2019

I have a custom scaled circle legend I am using to indicate values associated with circle marker size in leaflet but I would like to be able to show/hide the circles as well as the legend with the group control feature.

The group arg is available in the addLegend function but not with addControl. Would it be possible to add this feature? I know this is achievable using workarounds in shiny (https://stackoverflow.com/questions/50373497/r-leaflet-show-hide-addcontrol-element-with-group-layers) but I am I not using shiny in this case.

Something like this:

leaflet(data) %>% 
  addCircleMarkers(lng = ~lon, lat = ~lat, radius = ~radius, group = "Circles") %>%
  addControl(html, group = "Circles") %>%
  addLayersControl(baseGroups = c("Circles"))

Thanks!

@PaulC91
Copy link
Author

PaulC91 commented Oct 14, 2019

I worked out how to do this. Integrated into a new addCustomLegend function so let me know if you want a PR!

But now I've ran into issue #477 in that legend layer control only works with overlayGroups. I think allowing legends to be part of baseGroups would be super useful so +1 for finding a solution to that.

Thanks.

@vojtechkania
Copy link

Have you already figured out a solution working for baseGroups?

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