leaflet-groupedlayercontrol
leaflet-groupedlayercontrol copied to clipboard
Adding feature to make individual groups collapsable
I have found that while using this library, I sometimes end up with an extremely large list of layers that can be added to a (sometimes quite small) map. The best solution I have found for dealing with this is to make each group of layers individually collapsible, allowing a user to quickly and easily locate the layers they are interested in without being overwhelmed by the full list of layers.
I have added the following options: groupsCollapsable: defaults to False. If True, all groups are collapsible and start off collapsed. groupsCollapsedClass, groupsExpandedClass: The css class(es) used to control the toggle icon for each group. Defaults to showing a simple + or - icon, but works with custom classes such as "glyphicon glyphicon-chevron-right" to use bootstrap glyphicons.
Example of usage with Bootstrap Glyphicons (Not dependent upon bootstrap)
I discovered the need for this independently from Issue #20 which I discovered after making this pull request.
Thanks for this, works great and also fixes the error I had where some layers can't be removed from the Layer Control.
I have finished updating the pull request.
-
The new features added are entirely optional and no existing implementations will be impacted.
-
I have added a section to the readme explaining how to enable the feature if they desire
-
I have provided 2 examples, a basic and advanced version to show how to use bootstrap classes to override the default behavior
-
I have fixed the indenting to conform with your preferred two-space method
-
I have not removed the fix for removeLayer() as you requested because the current implementation/previous fix is still incorrect as I explain in a separate review.
If you require any further changes please let me know and I should be able to make it happen.
Can we make this pull request a thing? If help is needed, please give me a heads up - i would like to use such a feature!