tomroh / leaflegend

Provides extensions to the leaflet R package to customize legends with images, text styling, orientation, sizing, and symbology.
https://leaflegend.delveds.com
Other
35 stars 3 forks source link

Leaflet Group Support #25

Closed radbasa closed 3 years ago

radbasa commented 3 years ago

I wished there was support for Leaflet groups, to be able to show/hide the legend using leaflet layer control.

But since this uses leaflet::addControl(), that might not be possible.

I'll try to see if it can be done via Javascript.

tomroh commented 3 years ago

Yes, groups are currently not supported. A little javascript might be required for turning on/off layers. An easy button could work as well.

radbasa commented 3 years ago

I hope you don't mind. I added support for leaflet::addLayersControl(). It does not work exactly like how leaflet does it. I did it in using CSS classes and Javascript. Added group and className to the function parameters. Works for both baseGroups and overlayGroups.

This is my first time to modify a package. For now, I put my example/test code in its own folder. I am not sure if I should put examples in the roxygen blocks or in a separate file. I'll defer to you on that. I'll polish my work before I submit a pull request.

https://github.com/radbasa/leaflegend/tree/feature/leafletgroupsupport

tomroh commented 3 years ago

This issue is related to:

https://github.com/rstudio/leaflet/issues/647

tomroh commented 3 years ago

Also, if you want to add a example put it in roxygen documentation at the end of the other code snippets. The examples folder is not included in the package build