I successfully showed a map using st.pydeck_chart a couple of months ago but now it doesn’t work, not locally or cloudly. The error message is: AttributeError: ‘Deck’ object has no attribute ‘deck_widget’
Is it because of the update of the package?
My code:
view_state = pdk.ViewState(
latitude=df_bos[“lat”].mean(), # The latitude of the view center
longitude=df_bos[“lon”].mean(), # The longitude of the view center
zoom=11, # View zoom level
pitch=0) # Tilt level
# Create a map layer with the given coordinates
layer1 = pdk.Layer(type = 'ScatterplotLayer', # layer type
data=df_bos, # data source
get_position='[lon, lat]', # coordinates
get_radius=500, # scatter radius
get_color=[0,0,255], # scatter color
pickable=True # work with tooltip
)
# Can create multiple layers in a map
# For more layer information
# https://deckgl.readthedocs.io/en/latest/layer.html
# Line layer https://pydeck.gl/gallery/line_layer.html
layer2 = pdk.Layer('ScatterplotLayer',
data=df_bos,
get_position='[lon, lat]',
get_radius=100,
get_color=[255,0,255],
pickable=True
)
stylish tool tip: Configuring tooltips — pydeck 0.6.1 documentation
tool_tip = {"html": "University Name:<br/> <b>{Name}</b>",
"style": { "backgroundColor": "orange",
"color": "white"}
}
# Create a map based on the view, layers, and tool tip
map = pdk.Deck(
map_style='mapbox://styles/mapbox/outdoors-v11', # Go to https://docs.mapbox.com/api/maps/styles/ for more map styles
initial_view_state=view_state,
layers=[layer1,layer2], # The following layer would be on top of the previous layers
tooltip= tool_tip
)
st.pydeck_chart(map) # Show the map in your app