question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LayerGroup support

See original GitHub issue

Short 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:open
  • Created 5 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

1reaction
Conengmocommented, Jan 22, 2019

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.

1reaction
Conengmocommented, Jan 14, 2019

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does leaflet support user defined Layer identifiers
If you place all your layers in the same L.featureGroup or L.layerGroup , like this: group = L.featureGroup().addTo(map); L.marker([34.07 ...
Read more >
Layer Groups — GeoServer 2.23.x User Manual
A layer group is a container in which layers and other layer groups can be organized ... By default this behaviour is inherited...
Read more >
Child components | React Leaflet
Child components in React Leaflet support common behaviors described below, ... import { LayerGroup } from 'https://cdn.esm.sh/react-leaflet/LayerGroup'.
Read more >
To Create a Layer Group (AutoCAD Mechanical Toolset)
Need Help? Tell us about your issue and find the best support option. Contact Support ...
Read more >
Move the Current layer to active Layer group - 8526780
This small script should help – provided you have a reference to the LayerSet, you can move a Layer into it: var doc...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found