python-visualization/folium

LayerGroup support

已關閉

#1,034 建立於 2018年12月6日

 (13 則留言) (1 個反應) (0 位負責人)Python (2,245 個分叉)batch import
enhancementgood first issuehelp wanted

倉庫指標

星標
 (6,527 顆星)
PR 合併指標
 (平均合併 5天 7小時) (30 天內合併 5 個 PR)

描述

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!

貢獻者指南