Pydeck_chart two way communication? how to select data on map?

Hi all,

I’ve been using streamlit a lot, it’s amazing.
One thing that would be super awesome to have is to have two way communication for pydeck_chart
e.g. in Jupyter notebook:

import pandas as pd
import requests

json = requests.get(DATA_URL).json()
df = pd.DataFrame(json["features"][0]["geometry"]["coordinates"])
df.columns = ['lng', 'lat']

viewport = pdk.data_utils.compute_view(df[['lng', 'lat']])
layer = pdk.Layer(
    'ScreenGridLayer',
    df,
    cell_size_pixels=20,
    color_range=COLOR_RANGE,
    get_position='[lng, lat]',
    pickable=True,
    auto_highlight=True)
r = pdk.Deck(layers=[layer], initial_view_state=viewport)
r.show()

and you can click on the map and get selected data by doing:

pd.DataFrame([r.deck_widget.selected_data])

is there anyway to have something like:

mychart = st.pydeck_chart(r)

then when I click on the map, I can access the data behind call back and get it by doing something like

df = pd.DataFrame([mychart.selected_data])
1 Like

Hey @SPTKL, welcome to the forums! :tada:

This is not possible today, but we do want to do this, this year. See this bug and the FR for plugins

3 Likes

Any Update on this ?

I was also looking for this bidirectional communication functionality. Is it available now?

1 Like

Any news?

Any?

Have you tried out Streamlit Folium? It’s not Pydeck but it does enable bidirectional communication in mapping GitHub - randyzwitch/streamlit-folium: Streamlit Component for rendering Folium maps

1 Like

Thanks, I’m going to try it.
At the moment I would like to ask another question, is there a way to get the html code of the streamlit application at a certain point in the application flow?
Again, thanks for the help.

Any news on this? Very much looking forward to this feature! Will try out folium in the meantime. See this discussion on the same topic: Event Handling of pydeck_chart map in streamlit