Ask Your Question
2

How can markers layer be kept in front in Folium version 0.11.0?

asked 2021-12-13 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-03-07 13:00:00 +0000

pufferfish gravatar image

You can use the ControlLayer class to add a LayerControl to your map and then specify the ordering of the layers using the add_overlay method of the Map object.

Here's an example code snippet:

import folium

# create map object
m = folium.Map()

# create marker layer
marker_layer = folium.FeatureGroup(name='Markers')
marker = folium.Marker(location=[40.7128, -74.0060])
marker.add_to(marker_layer)

# add layers to map
marker_layer.add_to(m)
folium.LayerControl().add_to(m)

# reorder layers
m.add_child(folium.map.LayerControl(collapsed=False, position='bottomright'))

# display the map
m

In this example, we first create a marker layer and add a marker to it. Then, we add the marker layer to the map and create a LayerControl using the ControlLayer class. Finally, we add the LayerControl to the map and reorder the layers so that the marker layer is on top.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-12-13 11:00:00 +0000

Seen: 1 times

Last updated: Mar 07 '22