St_folium Not passing along folium.geojsontooltip style

Hi,

I have been trying to style hover tooltips on folium maps and have been running into trouble with passing along styling to my streamlit app via streamlit-folium.

Here is my code below:

m2 = folium.Map(location=[lat, lon], zoom_start = 6, min_zoom = 5, max_zoom = 7)

tooltip = folium.GeoJsonTooltip(
fields=[“X”, “Y”, “Z”],
aliases=["X: ", “Y: “, “Z: “],
localize=True,
sticky=False,
labels=True,
style=”””
background-color: #F0EFEF;
border: 2px solid black;
border-radius: 3px;
box-shadow: 3px;
text-align: right;
“””,
max_width=800

m2.add_child(folium.GeoJson(df2.head(1),
style_function=lambda x:{
‘fillColor’: ‘#DF1111’,
‘fillOpacity’: .4,
‘color’: ‘black’,
‘Opacity’: .9,
‘weight’: .6
},
tooltip=tooltip)
)

st_folium(m2, center=st.session_state[“center”], zoom=6, height = hgt, width = wdt, use_container_width = True, returned_objects=)

The formatting from st_folium outputs the map tooltips as the default tooltip, with no formatting changes. I’ve saved the html to my drive and the map appears with all styling included, so I’ve narrowed down the problem to the actual passing of the map to streamlit via st_folium.

Has anyone found a way to resolve this? Thank you.

R

Hi @robstreamlit, welcome to the forum!

Would you mind doing a couple of things to improve this post?

  1. Format your code as code, using ``` so that it’s possible to copy and paste it
  2. Make the code snippet work exactly as-is, without any undefined variables (like lat, hgt, df2, etc.)
  3. Post which version of streamlit and streamlit-folium you’re using (and try updating to the latest versions just in case it helps)

Since this is related to streamlit, it’s fine to post it here, but since it’s about a specific component, it might be better to post it as an issue here Issues · randyzwitch/streamlit-folium · GitHub

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