Hello, Plotly comunity,
I’d like to show a group of maps which all respond to zoom and pan operations in any one of them, just as shared_xaxes=‘all’ and shared_yaxes=‘all’ normally work for make_subplots with other trace types.
The maps are created OK, but I cannot get beyond the zoom/pan changes only affecting the current subplot.
I know I could do this backend by collecting changes to current center/zoom and spawn a callback to rescale/relocate all subplots with the collected valules. It would be nicer if it was possible client-side.
I am doing this in a Shiny app, but the figure itself is created by the following function:
def InitiateMultiPlot():
ncols = 3
nrows = 2
mapnames = ['ODM_HydMetGeo', 'ODM_RelVanninnhold',
'ODM_RelVannTilførsel','GWB_HydMetGeo', '
GWB_RelVanninnhold', 'GWB_RelVannTilførsel']
fig = make_subplots(rows=nrows, cols=ncols,
specs=[[{"type": "map"}, {"type": "map"}, {"type": "map"}],
[{"type": "map"}, {"type": "map"}, {"type": "map"}]
],
shared_xaxes='all', shared_yaxes='all', horizontal_spacing=0.02,
vertical_spacing=0.04, subplot_titles=mapnames
)
for plotno, imgname in enumerate(mapnames):
row = plotno//ncols+1
col = plotno%ncols+1
showlegend = (plotno==0) # Only show one legend
fig.add_trace(go.Scattermap(name = imgname, mode = 'markers',
hoverinfo = 'text', showlegend=showlegend),
row=row, col=col)
fig.update_geos(projection_type="mercator")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}, clickmode='event+select', height=1000)
cur_zoom = 4.5
cur_center = [65, 18]
fig.update_maps(style='open-street-map', zoom=cur_zoom,
center = {"lat": cur_center[0], "lon": cur_center[1]})
return fig
All help appreciated.