New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st_folium keeps reloading Streamlit page till page crashes #72
Comments
What version are you using? Can you also provide the code that creates your |
I have same issue. Rendering folium using st_folium itself triggers streamlit reloading. So, streamlit reloades the page infinitely. Below is my code that creates
|
I found this line does not work. windows.map is undefined still after the map has been created. So, it re-renders infinitely.
By removing streamlit-folium/streamlit_folium/frontend/src/index.tsx Lines 83 to 96 in 52c7b88
|
Thanks for digging into this Paul, we'll take a look at this to see if it solves the problem more globally! |
@PaulShin83 I don't see that issue when I fun the following script with streamlit==1.11.0 and streamlit-folium==0.6.13 import streamlit as st
from streamlit_folium import st_folium
import folium
def draw_folium_map():
center = [39.5, -98.5]
tiles = ["cartodbpositron", "Stamen Toner", "OpenStreetMap"]
map = folium.Map(
location=[center[0], center[1]],
zoom_start=10,
zoom_control=True,
scrollWheelZoom=False,
tiles=tiles[0],
)
folium.Marker(
location=[39.5, -98.5],
popup=f"A location!",
icon=folium.Icon(color="blue", icon="star"),
).add_to(map)
return map
m = draw_folium_map()
output = st_folium(m, key="map", width=650, height=600)
st.write(output) I know this isn't exactly the same as your script, but I'm unable to run your exact example without the full script. It's possible that the issue you're encountering is related to something happening with session state (e.g. perhaps rendering the map -> updates session state -> rerendering the map -> ...). Would you be able to share the full script, or a complete subset of it that shows the infinite-reload issue? |
@blackary I found it while I am trying to reproduce the issue that using import streamlit as st
from streamlit_folium import st_folium
import folium
def draw_folium_map():
center = [39.5, -98.5]
tiles = ["cartodbpositron", "Stamen Toner", "OpenStreetMap"]
map = folium.Map(
location=[center[0], center[1]],
zoom_start=10,
zoom_control=True,
scrollWheelZoom=False,
tiles=tiles[0],
)
folium.Marker(
location=[39.5, -98.5],
popup=f"A location!",
icon=folium.Icon(color="blue", icon="star"),
).add_to(map)
return map
def main():
map_placeholder = st.empty()
col1, col2, col3 = st.columns(3)
# check1 = col1.checkbox("check1", True)
col4, col5, col6 = st.columns(3)
# check1 = col4.checkbox("check2", True)
map = draw_folium_map()
with map_placeholder.container():
output = st_folium(map, width=700, height=450, key='foliumMap1')
st.write(output)
if __name__ == '__main__':
main() |
@PaulShin83 I tried reproducing what you are seeing, and I am not seeing any rerendering issue. Here is a hosted version of your app https://blackary-folium-bug-streamlit-app-rpsil3.streamlitapp.com/. Are you seeing the repeated rerendering there? |
Sorry I can't provide more detail, but I also had this problem and had it fixed by using the static function, and would like to advocate for it to not be deprecated. |
Same problem here. |
@joaoambiente Can you share a reproducible code snippet that shows this behavior? |
I believe I might be facing the same issue, has it been fixed in recent updates ? |
How about:
The problem on my end is that loading this much stuff takes time. Regarding: "If there is a reason why folium_static() needs to remain, please leave a GitHub issue describing your use case." |
@tonkolviktor Thanks for sharing that example code! In this case, it seems to be behaving as expected -- I don't see it reloading over and over again. The "running guy" does trigger, but that is because the map is returning different values. If you want to avoid this, you can pass |
Streamlit page keeps reloading every 3 seconds till it crashes. Now I use st_static that is not recommended ?
st_data = st_folium(m, key='map',width = 650, height = 600)
Any idea what is happening ?
The text was updated successfully, but these errors were encountered: