streamlit-folium icon indicating copy to clipboard operation
streamlit-folium copied to clipboard

Draw doesn't work on timeseries figure

Open this-josh opened this issue 1 year ago • 2 comments
trafficstars

I think this is similar to #161 which was closed by #162. The error experienced is the same as #161 where after drawing icons the tool doesn't reset and the returned object doesn't include the selected points.

SCR-20231214-hxlj

Reproduce with:

folium                    0.15.1   
streamlit                 1.29.0   
streamlit-folium          0.17.4

and

import folium
from streamlit_folium import st_folium
from folium.plugins import Draw
import streamlit as st

m = folium.Map(location=[35.68159659061569, 139.76451516151428], zoom_start=16)

# Lon, Lat order.
lines = [
    {
        "coordinates": [
            [139.76451516151428, 35.68159659061569],
            [139.75964426994324, 35.682590062684206],
        ],
        "dates": ["2017-06-02T00:00:00", "2017-06-02T00:10:00"],
        "color": "red",
    },
]

features = [
    {
        "type": "Feature",
        "geometry": {
            "type": "LineString",
            "coordinates": line["coordinates"],
        },
        "properties": {
            "times": line["dates"],
        },
    }
    for line in lines
]

folium.plugins.TimestampedGeoJson(
    {
        "type": "FeatureCollection",
        "features": features,
    },
    period="PT1M",
    add_last_point=True,
).add_to(m)
Draw(export=True).add_to(m)
m.save('draw.html')
c1, c2 = st.columns(2)
with c1:
    output = st_folium(m, width=700, height=500)

with c2:
    st.write(output)

Note all we get expected behaviour with:

folium                    0.14.0
streamlit                 1.29.0
streamlit-folium          0.14.0

this-josh avatar Dec 14 '23 08:12 this-josh

Note this behaviour still exists with

folium==0.15.1
streamlit==1.31.1
streamlit-folium==0.18.0

in Python 3.12.2

this-josh avatar Feb 28 '24 09:02 this-josh

Here is the console error message

SCR-20240228-invd

this-josh avatar Feb 28 '24 09:02 this-josh