I am not sure what goes wrong with Scattermapbox, but with Dash Leaflet, the desired behavior can be achieved in a few lines. Here is a MWE for illustration,
import dash
import dash_html_components as html
import dash_leaflet as dl
# Setup some dummy data.
count, delta, center = 5, 0.1, [56, 10]
positions = [[center[0] - delta*(i - count/2), center[1]] for i in range(count)]
labels = [str(chr(97 + i)) for i in range(count)]
# Create markers with text.
markers = [dl.Marker(position=pos, children=[dl.Tooltip(labels[i])]) for i, pos in enumerate(positions)]
# Create small example app.
app = dash.Dash()
app.layout = html.Div([
dl.Map(center=center, zoom=9, style={'width': '1000px', 'height': '500px'}, children=[dl.TileLayer()] + markers)
])
if __name__ == '__main__':
app.run_server(debug=False)
When you post a question like this, a self-contained example (i.e. a piece of code that can run) that illustrates the problem would be helpful
Hi @Ud29, welcome to the forum. There is indeed an open issue about this problem https://github.com/plotly/plotly.js/issues/4110. If you can use a mapbox style (with a free token) the problem disappears. This could be a workaround until the problem is fixed.
In case it’s useful to anyone else, go.Choroplethmapbox.mapbox_style accepts mapbox:// custom style URL. In my case, I wanted a plain white background and was originally using:
go.Layout(
mapbox_style='white-bg',
...
)
but per bug report, the “non-mapbox” style prevents rendering of text. Logging in to mapbox and creating a new custom style via https://studio.mapbox.com/ solved this issue for me: