Skip to content
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

Copy the example code but cannot run #4

Open
TTa77 opened this issue Apr 7, 2024 · 2 comments
Open

Copy the example code but cannot run #4

TTa77 opened this issue Apr 7, 2024 · 2 comments

Comments

@TTa77
Copy link

TTa77 commented Apr 7, 2024

webpage_milestone2.Streamlit.-.Google.Chrome.2024-04-07.07-54-46.mp4

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!

@TTa77 TTa77 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2024
@TTa77 TTa77 reopened this Apr 7, 2024
@reyemb
Copy link
Owner

reyemb commented May 2, 2024

I am sorry for catching up late

Can you tell the version you are using?

@CarloC-AB
Copy link

It's happening with me still and tested all 3 versions, 0.1.0, 0.1.1, and 0.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants