python-visualization/folium

LayerGroup support

クローズ

#1,034 opened on 2018/12/06

 (13 件のコメント) (1 件のリアクション) (0 人の担当者)Python (2,245 件のフォーク)batch import
enhancementgood first issuehelp wanted

Repository metrics

Stars
 (6,527 個のスター)
PR merge metrics
 (平均マージ 5d 7h) (30d で 5 merged PRs)

説明

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!

コントリビューターガイド