-
Hello. I'd like help on changing the colors, line thickness, and fill for layers. I tried the "style" option from ipyleaflets for the folium plotting backend. But it doesn't work. I'd appreciate some examples. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
In folium, the style parameter name is called https://python-visualization.github.io/folium/quickstart.html#Styling-function |
Beta Was this translation helpful? Give feedback.
-
See the example below import leafmap.foliumap as leafmap
Map = leafmap.Map(center=[0, 0], zoom=2)
url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
def style(feature):
return {
"stroke": True,
"color": "#0000ff",
"weight": 2,
"opacity": 1,
"fill": True,
"fillColor": "#0000ff",
"fillOpacity": 0.1,
}
Map.add_geojson(url, layer_name="Countries", style_function=style)
Map |
Beta Was this translation helpful? Give feedback.
-
I just improved support for folium layer styles. Now the same code will work for both ipyleaflet and folium without making any changes. Check out the updated notebook example https://leafmap.org/notebooks/10_add_vector, which uses the folium plotting backend. You should get the same results using the ipyleaflet plotting backend. |
Beta Was this translation helpful? Give feedback.
See the example below