Closed martinfleis closed 3 years ago
I did not get the full extent of this, Would there be support for both layer groups and layer control ? I guess that can get a little complicated
This bit of code generates layer control (you can turn on and off layers).
m = view(world, name='world')
view(cities, name='cities', m=m)
folium.LayerControl().add_to(m)
m
I tried to hook it into view
but it does not seem to be possible. Layer control needs to be added after all layers are in the map, which we cannot control from within view
.
Not sure what layer groups are :).
Not sure what layer groups are :).
Oops though I linked it, I was referring to this plugin https://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Plugins.ipynb#FeatureGroupSubGroup
I tried to hook it into
view
but it does not seem to be possible. Layer control needs to be added after all layers are in the map, which we cannot control from withinview
.
Gotcha, I just noticed there is a map arg you can pass to view
😅 so I guess you can call LayerControl
inside view
only when you know it's gonna be the final layer that you add, and if someone further adds a new layer then they would need to explicitly set control=False
or it would just delete the whole LayerControl thing (adding onto your example)
m = view(world, name='world')
view(cities, name='cities', m=m)
folium.LayerControl().add_to(m)
folium.TileLayer('Stamen Terrain',control=False).add_to(m)
m
Does this seem like a feature that people should use directly through folium
? or there could be layercontrol
arg which would also have its own set of kwargs like ZIndex
or there could be layercontrol arg which would also have its own set of kwargs like ZIndex
I am not sure if we'll be able to do this in reality.
Does this seem like a feature that people should use directly through folium?
This may be fine, we just need to make sure to document this (we should maybe start a notebook working as a user guide).
folium.LayerControl()
works only after all layers are in and is removed if a new layer is added to a map, so it is not easy to have it within view. We should optimally figure out a way how to add layer control without the necessity to callfolium.LayerControl()
afterview()
manually.