streamlit-plotly-mapbox-events
streamlit-plotly-mapbox-events copied to clipboard
Copy the example code but cannot run
https://github.com/reyemb/streamlit-plotly-mapbox-events/assets/71015547/8e4b74ae-d961-4689-a004-25a2bf579e21
Could you please help me about this? The webpage is continuously refreshing and I cannot do anything on it.
I am running your example code without any change:
import streamlit as st
from streamlit_plotly_mapbox_events import plotly_mapbox_events
import plotly.express as px
import pandas as pd
# Create a sample dataframe
df = pd.DataFrame({
'lat': [49.058, 50.383, 49.599, 50.677, 53.036, 50.541, 51.524, 54.992, 49.88],
'lon': [11.115, 12.528, 11.231, 10.408, 8.185, 8.055, 7.639, 11.636, 7.678],
'hover': [1, 2, 3, 4, 5, 6, 7, 8, 9],
'color_1': [3, 3, 4, 3, 5, 5, 5, 4, 2],
'color_2': [5, 5, 3, 1, 1, 2, 5, 2, 2],
'color_3': [3, 2, 1, 5, 3, 2, 5, 2, 2]
})
# Create a Plotly Mapbox figure
mapbox = px.scatter_mapbox(df, lat="lat", lon="lon", hover_name="hover", zoom=5.5, height=600)
mapbox.update_layout(mapbox_style="carto-positron")
mapbox.update_layout(margin={"r":0, "t":0, "l":0, "b":0})
# Create an instance of the plotly_mapbox_events component
mapbox_events = plotly_mapbox_events(
mapbox,
click_event=True,
select_event=True,
hover_event=True,
override_height=600
)
# Display the captured events
plot_name_holder_clicked = st.empty()
plot_name_holder_selected = st.empty()
plot_name_holder_hovered = st.empty()
plot_name_holder_clicked.write(f"Clicked Point: {mapbox_events[0]}")
plot_name_holder_selected.write(f"Selected Point: {mapbox_events[1]}")
plot_name_holder_hovered.write(f"Hovered Point: {mapbox_events[2]}")
Thank you!
I am sorry for catching up late
Can you tell the version you are using?
It's happening with me still and tested all 3 versions, 0.1.0, 0.1.1, and 0.1.2