LayerGroup support
See original GitHub issueShort question
Will Folium ever allow a generation of LayerGroup, or a decision had been made to keep only FeatureGroup?
Details
According to LeafletJS documentation, FeatureGroup extends LayerGroup. They have different JS constructors:
L.featureGroup(<Layer[]> layers)
with only a list of layers,
L.layerGroup(<Layer[]> layers?, <Object> options?)
with some options in addition to layers.
When creating a FeatureGroup in Folium, there is a parameter name
in its Python constructor (as well as some visualization-related params):
__init__(self, name=None, overlay=True, control=True, show=True)
However, this name
is only used to display a name of this featuregroup in a LayerControl:
var feature_group_bdeeee... = L.featureGroup(name="events").addTo(map_...);
var layer_control_... = {
base_layers : { "openstreetmap" : ...},
overlays : { "events" : feature_group_bdeeee... }
}
What I need to have in a generated code for my use-case is a constructor with those options parameter, proposed by LayerGroup:
var layer_group_2... = L.layerGroup(null, {'step': '2'})
This would allow to access those attributes (step in my example) of my featuregroup (layergroup) using some custom JS code to put listeners on some objects.
Example of use case: when hovering step=5
name in a custom div
element, 5th circle from events
group and 5th marker of another (say, places
) group change their CSS classes to highlight the connection between 5th “event” and “place”, a bit like zip
in Python.
To make it possible, i need L.layerGroup(null, {'step': '1'})
generated code instead of just empty L.featureGroup()
. I could write corresponding code and make a PR, if ever this functionality is welcomed by the community 😃
folium version 0.7.0.
Sorry if anything is unclear, this is the 1st issue i open. Don’t hesitate to ask for more details. Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10
Top GitHub Comments
I’m thinking now that adding this might help with some of the issues we’ve been having with the grouping of geojson layers. So if someone wants to pick this up that would be great. Should be straightforward to duplicate the current featuregroup implementation and alter it.
Hi @denisflash, I don’t think there was ever a conscious decision not to add layergroup. So we can definitely consider adding it. I don’t really understand your example though. Could you explain a bit more why you need layergroup, and featuregroup doesn’t work for you?