leaflet-groupedlayercontrol icon indicating copy to clipboard operation
leaflet-groupedlayercontrol copied to clipboard

Adding feature to make individual groups collapsable

Open ForgottenLords opened this issue 7 years ago • 3 comments

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.

collapsable groups 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.

ForgottenLords avatar Mar 16 '17 22:03 ForgottenLords

Thanks for this, works great and also fixes the error I had where some layers can't be removed from the Layer Control.

nadnerb33 avatar Jul 25 '17 12:07 nadnerb33

I have finished updating the pull request.

  1. The new features added are entirely optional and no existing implementations will be impacted.

  2. I have added a section to the readme explaining how to enable the feature if they desire

  3. I have provided 2 examples, a basic and advanced version to show how to use bootstrap classes to override the default behavior

  4. I have fixed the indenting to conform with your preferred two-space method

  5. 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.

ForgottenLords avatar Oct 30 '17 23:10 ForgottenLords

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!

JohnnyMoonlight avatar Mar 31 '22 09:03 JohnnyMoonlight