Style Function not working when adding markers to session state


Hello all. I am using streamlit to build an app where I have a map, perform some spatial operations through a function, and then want to add these polygons/points/lines to my main map. I do these by adding them through the st.session_state bit. I want these shapes to have a particular style, and usually I’d do that by adding some info to the style function in the folium.GeoJson(…) code snippet. But they don’t seem to pick up the style.

Steps to reproduce

Code snippet:

if 'markers' not in st.session_state:
    st.session_state["markers"] = []

fg = folium.FeatureGroup(name="Markers")
for marker in st.session_state["markers"]:

m = create_map()

map = st_folium(m,

def make_polygons():
style1 = {'lineColor': '#000000'}
intersect = folium.GeoJson(intersecting_polygons, style_function= lambda x: style1)

I expect it to pick up the style I have put in, but I get the default style.
An image of what I get below:

Hi @sim-arora

There appears to be existing resources on coloring for folium geojson function that you could look into:

Got the same problem. Existing resources seems to be ignored when used in a feature_group_to_add

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.