randyzwitch / streamlit-folium

Streamlit Component for rendering Folium maps
https://folium.streamlit.app/
MIT License
468 stars 176 forks source link

Draw example doesn't work with `folium = ^0.15.0` #161

Closed this-josh closed 10 months ago

this-josh commented 10 months ago

Sorry I know I've raised a lot of tickets recently, I just believe it's good to raise them when found.

The draw example from your docs (they seem to be down currently so cannot link them)

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)

Doesn't work with ^0.15.0 (I am using 0.15.1 specifically.

After placing a marker it dones't deselect the tool, and the markers location is not updated in the output: image

Versions

folium                    0.15.1
streamlit                 1.29.0
streamlit-folium          0.17.2

Thanks, Josh

this-josh commented 10 months ago

FYI this is https://folium.streamlit.app/ currently

image

this-josh commented 10 months ago

Scratch that, the docs are fine now, just down for a few minutes

this-josh commented 10 months ago

By the way I've seen that you don't support 0.15.0, note your requirements.txt doesn't exclude 0.15.1 which might be your desired scenario.

If you don't want to support 0.15.x change this folium>=0.13,!=0.15.0 to folium>=0.13,<0.15.0

https://github.com/randyzwitch/streamlit-folium/blob/abb655e9e96ed77b5f65fb5cec29b9ba35f0e501/requirements.txt#L2

randyzwitch commented 10 months ago

By the way I've seen that you don't support 0.15.0, note your requirements.txt doesn't exclude 0.15.1 which might be your desired scenario.

No, that is the intended scenario. 0.15.0 of Folium made a change to its internals, which broke this package. 0.15.1 of Folium made a change that was intended to fix it, so we intended to support just that patch version and going forward.

However, the Folium change may have broken more than we expect, which might be what you are seeing with this functionality.

blackary commented 10 months ago

I'm not seeing that behavior on the draw page -- it seems to be working fine

image
this-josh commented 10 months ago

Hm? Are you using a clean env with the same versions as I mentioned above?

I've recreated my env and still experience the issue on both Chrome and Safari

this-josh commented 10 months ago

I can also reproduce it with streamlit-folium 0.17.1

But it the draw functionality works with

folium                    0.14.0
streamlit                 1.29.0
streamlit-folium          0.16.0
patrontheo commented 10 months ago

I also had a issues with the draw plugin and latest version of each packages (when drawing squares). I downgraded to folium 0.14 and streamlit-folium 0.16 and it works.

this-josh commented 10 months ago

Interestingly the export button exports the correct data

blackary commented 10 months ago

Sorry about that @this-josh, I thought you meant that the drawing example was broken on https://folium.streamlit.app, which is what I was testing.

162 should resolve this issue

hansthen commented 9 months ago

I have the same error. If it helps, in the browser console, I see this message:

index.tsx:137 Uncaught TypeError: Cannot read properties of undefined (reading 'toGeoJSON')
    at onLayerClick (index.tsx:137:25)
    at i.onDraw (index.tsx:108:10)
    at i.fire (Events.js:190:11)
    at i._fireCreatedEvent (leaflet.draw.js:8:3599)
    at i._fireCreatedEvent (leaflet.draw.js:8:18428)
    at i._onMouseUp (leaflet.draw.js:8:17214)
    at i._onMouseUp (leaflet.draw.js:8:18039)
    at c (DomEvent.js:92:13)
    at Ut (DomEvent.Pointer.js:98:2)
    at HTMLDocument.o [as _leaflet_touchendtouchend129_68] (DomEvent.Pointer.js:117:3)
this-josh commented 9 months ago

Are you on streamlit_folium 0.17.4? This should be fixed.