Creating two different scatter_mapbox, one often fails
@archmoj is already working on this.
Since Jul 25, 2024.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
I create two different scatter_mapbox with similar data.
Sample:
div_mapbox = html.Div([dcc.Graph(figure=figure, id='figmapbox', style={'width': '90vw', 'height': '90vh'})],
id = 'divmapbox',
style={'width': '90%', 'display': 'inline-block', 'height': '90%', 'position': 'absolute', 'z-index': '1'}
)
With figure either:
def get_fig_openseamap(wpts):
fig = px.scatter_mapbox(data_frame=wpts, lat="lat", lon="lon", size='size_marker', size_max=8, opacity=1.0, hover_data={'size_marker': False, 'lat':False, 'lon': False, 'energy': True, 'dist': True, 'eta': True})
fig2 = px.line_mapbox(data_frame=wpts, lat="lat", lon="lon")
fig.add_trace(fig2.data[0])
fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(mapbox_layers=[source_openseamap])
fig.update({'layout':{'autosize':True,
'margin': {"t": 5,"b": 5,"l": 5,"r": 5}}})
return fig
Or:
def get_fig_northstar(wpts):
fig = px.line_mapbox(data_frame=wpts, lat="lat", lon="lon")
fig2 = px.scatter_mapbox(data_frame=wpts.query('ghost == 0'), lat="lat", lon="lon", opacity=1, hover_data={'lat': False, 'lon': False, 'energy': True, 'dist': True, 'eta': True})
fig.add_trace(fig2.data[0])
fig.update_layout(mapbox_style=mapbox_style_northstar)
fig.update({'layout':{'autosize':True,
'margin': {"t": 5,"b": 5,"l": 5,"r": 5}}})
return fig
Where openseamap layer is the openseamap marks tile.
Nothstar is the official mapbox style northstar, that needs to be copied into a personal account to work.
I can run each of them on its own, no problems. Sometimes, running both works, and sometimes it fails.
The failure normally appears like one map working perfect, the other has no graphics, BUT the hoverlayer works, so hovering over a point (that cant be seen) shows the hover data.
It seems a bit stochastic to me.
I can also replace the figure with callbacks using Output('figmapbox', 'figure')
As long as it's one at a time, it works fine. Having both can work but normally not.
Any suggestions how to debug this? I have suspected race conditions and tried delaying creating one of them but saw no improvement.
dash 2.8.1
dash-core-components 2.0.0
dash-daq 0.5.0
dash-html-components 2.0.0
OS: pop_os 22.04 (ubuntu 22.04)
Chrome 110.0.5481.96 (Official Build) (64-bit)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.