Hello,
I am trying to access the coordinates pertaining to the bounding box of a Plotly Mapbox figure (essentially the min and max latitude and longitude in view at any given time). Does anyone know how such information about the figure might be accessed? I am working in Python + Dash, and am thinking a callback will need to be constructed to retrieve this information when a user either pans or zooms in on the Mapbox figure.
Any help would be greatly appreciated!
Minimal working example (will require a mapbox token)
import plotly.graph_objects as go
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
fig = go.Figure()
fig.add_trace(go.Scattermapbox(mode = "markers+lines"))
fig.update_layout(
autosize=True,
hovermode='closest',
showlegend=True,
margin=dict(t=20, b=0, l=0, r=0),
mapbox=dict(
# Access token comes from https://docs.mapbox.com/help/glossary/access-token/
accesstoken= "Insert MapBox Token Key Here",
bearing=0,
pitch=0,
zoom=3,
style="satellite-streets"
),
)
app = JupyterDash(__name__)
app.layout = html.Div([
dcc.Graph(figure=fig)
])
app.run_server(mode="jupyterlab",debug=True)
2 posts - 2 participants