But every time I draw a shape, it seems that the mouse gets stuck
Steps to reproduce
Code snippet:
import folium
import streamlit as st
from folium.plugins import Draw
from streamlit_folium import st_folium
m = folium.Map(location=[39.949610, -75.150282], zoom_start=5)
Draw(export=True).add_to(m)
c1, c2 = st.columns(2)
with c1:
output = st_folium(m, width=700, height=500)
with c2:
st.write(output)
Expected behavior:
I expect that every time a release the mouse button, the drawing will stop
Actual behavior:
Every time I release the mouse button, the drawing continues.
Debug info
Streamlit version: 1.31.0
Python version: 3.10.11
Using Conda? Conda, PipEnv
OS version:
Browser version: Firefox
Requirements file
streamlit==1.31.0
streamlit-folium==0.12.0 also tried the latest version
Here’s an example of how to address the issue using custom JavaScript, though this approach might not directly solve the mouse release problem:
import folium
import streamlit as st
from streamlit_folium import st_folium
from folium.plugins import Draw
m = folium.Map(location=[39.949610, -75.150282], zoom_start=5)
Draw(export=True).add_to(m)
# Attempt to capture and correct mouse events via JavaScript
# This is a simplistic approach and may need adjustments
js = """
<script>
document.addEventListener('mouseup', function() {
// Custom logic to forcibly stop drawing or reset tool state
});
</script>
"""
st.markdown(js, unsafe_allow_html=True)
result = st_folium(m, width=700, height=500)
Hope this helps!
Kind Regards,
Sahir Maharaj
Data Scientist | AI Engineer
Did you fix the problem? I got the same error as above. However, in my case, the page above works fine, but in my code I got a problem. Maybe something in my code conflicts with Draw(). In my case, I used fit_bounds() and Draw() in the code, but after moving fit_bounds() to Draw() declaration, the problem was solved. Even now, I’m not sure why.
I’m going through he same problem. Did anyone find a solution?
In my case, the release button stops working after click on the marker.
Here it is my code:
import folium
import streamlit as st
from folium.plugins import Draw
from streamlit_folium import st_folium
m = folium.Map(location=[43.72299, 10.396579], zoom_start=13)
Draw(export=True).add_to(m)
folium.Marker(
location=[43.72299, 10.396579],
popup="Torre di Pisa"
).add_to(m)
c1, c2 = st.columns(2)
with c1:
output = st_folium(m, use_container_width=True)
with c2:
st.write(output)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.