Skip to content

Add LayerGroup support (#1034)#2228

Open
TheChyeahhh wants to merge 2 commits into
python-visualization:mainfrom
TheChyeahhh:feat/layergroup-support
Open

Add LayerGroup support (#1034)#2228
TheChyeahhh wants to merge 2 commits into
python-visualization:mainfrom
TheChyeahhh:feat/layergroup-support

Conversation

@TheChyeahhh
Copy link
Copy Markdown

Closes #1034

Adds a new LayerGroup class to folium that mirrors FeatureGroup but uses L.layerGroup() in the generated JavaScript instead of L.featureGroup().

In LeafletJS, L.layerGroup(layers?, options?) accepts additional custom options that can be used in custom JavaScript code, while L.featureGroup(layers) does not support options.

This is a lightweight addition — the class shares the same Layer parent and behaves identically to FeatureGroup for rendering and layer control purposes.

Changes:

  • folium/map.py: Added LayerGroup class with L.layerGroup() template
  • folium/__init__.py: Export LayerGroup
  • tests/test_folium.py: Added test for LayerGroup rendering and custom options

Add a LayerGroup class that mirrors FeatureGroup but uses
L.layerGroup() instead of L.featureGroup() in the generated
JavaScript, allowing custom options to be passed through
to the Leaflet LayerGroup constructor.

Closes python-visualization#1034
@hansthen
Copy link
Copy Markdown
Collaborator

Interesting PR. I had to run black on the code because it did not comply with the style guide. Can you give a concrete example when this would be useful? It would be nice if we had some documentation for this class.

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

Successfully merging this pull request may close these issues.

LayerGroup support

2 participants