Add LayerGroup support (#1034)#2228
Open
TheChyeahhh wants to merge 2 commits into
Open
Conversation
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
for more information, see https://pre-commit.ci
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1034
Adds a new
LayerGroupclass to folium that mirrorsFeatureGroupbut usesL.layerGroup()in the generated JavaScript instead ofL.featureGroup().In LeafletJS,
L.layerGroup(layers?, options?)accepts additional custom options that can be used in custom JavaScript code, whileL.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: AddedLayerGroupclass withL.layerGroup()templatefolium/__init__.py: ExportLayerGrouptests/test_folium.py: Added test for LayerGroup rendering and custom options