Black Lives Matter. Please consider donating to Black Girls Code today.

Scattermapbox: Doesn't work with marker mode as "text"

Hello Plotly Community,

I would like to display the location of oil and gas wells over an open-street-map as markers along with static text ( well names on the map).

I have the following code:

 data = [
                'lon': longs,
                'lat': lats,
                'text': text,
                'type': 'scattermapbox',
                'mode': "markers+text",
            'color': '#636efa',
            'size': 8,

where longs -> list of longitude points, lats-> list of latitude points -> list of Well names

 layout = {
        'title': 'Well locations',
        'mapbox': {'style': "open-street-map", 'center': {'lat': 80, 'lon': 80},'zoom': 8},
        'autosize': False,
        'margin': {"r": 0, "t": 0, "l": 0, "b": 0},
        'hovermode': 'closest',
        'showlegend': False,
        'height': 1080


With this code, neither the marker points nor the text appears on the map. If I use mode as “markers” it works alright.

Could you please point me to what could be wrong with this code?


Hi @Ud29,

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__':

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 :slight_smile:


1 Like

Hi @Ud29, welcome to the forum. There is indeed an open issue about this problem 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:


but per bug report, the “non-mapbox” style prevents rendering of text. Logging in to mapbox and creating a new custom style via solved this issue for me:

map_layout = go.Layout(

Hi, what is the mapbox style workaround?
I’ve tried using ‘streets’ and ‘open-streets-map’ as the mapbox_style for a scatter_mapbox, but the text still doesn’t show. I looked at @despondentcoder129 suggestion but I don’t see anything for text of added points to a map, just the map components.
Would you mind providing an example of the workaround so I can try and get the labels on my map points working? Thank you :slight_smile: