When using a dcc.Loading
component to wrap a mapbox
figure, the uirevision
stops working. This is probably due to the fact that the Loading
component somehow destroys and recreates the mapbox
figure, but it would be interesting to hear if this is a known side-effect. I actually would like to be able to maintain the current map view while selecting options from multiple drop-down menus that change the data and map properties.
Assuming the map figure is generated like this (notice the uirevision
in the layout):
map_figure = {
'data': map_content,
'layout':
go.Layout(title='',
autosize=True,
height=h,
width=w,
margin=go.layout.Margin(l=0, r=0, t=0, b=0),
showlegend=show_legend,
mapbox=dict(
accesstoken='pk.123456789...',
center=dict(
lat=center_lat,
lon=center_lon
),
style=map_style,
bearing=0,
zoom=zoom
),
uirevision='default')
}
When this figure is integrated into the layout with a basic setup like this: html.Div(dcc.Graph(id='map-graph'))
the zoom
and lat
lon
coordinates are persistent and I can use drop-downs to switch between a satellite and map view without the callback resetting those properties. However, when I add a dcc.Loading
component around it, the persistence to longer works:
dcc.Loading(id=load_id,
type="circle",
style={'width': '100%'},
children=dcc.Graph(id='map-graph')
)
In our scenario the dcc.Loading
component would probably only be required when the map is first being generated. It is during that time - when the user can not yet see the actual map, yet - that the loading spinner really makes sense. After that, having the map disappear and re-appear actually isn’t a great user experience.
It would be great if the dcc.Loading
component could be configured to either just load once at an initialisation phase or perhaps become an overlay feature that sits transparently on top of the existing content without hiding it.
Please share if you have any potential solutions or workarounds so that I could still have the uirevision
flag working as expected.