Scatter mapbox Vector Tile Maps

Can I prescribe a third party vector tile map? I tried to set it up using the mapbox_layers layout property but nothing shows up in the background (code below). Wondering if the mapbox_layers can leverage the the VectorTileLayer object in mapbox.

I want to use the ESRI vector topo map.

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.express as px

us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv")


fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
                        color_discrete_sequence=["fuchsia"], zoom=3, height=300)
fig.update_layout(
    mapbox_style="white-bg",
    mapbox_layers=[
        {
            "below": 'traces',
            "sourcetype": "vector",
            "sourceattribution": "ESRI",
            "source": [
                "https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf"
            ],
            "sourcelayer":""
        }
      ])
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})


app = dash.Dash()
app.layout = html.Div([
    dcc.Graph(figure=fig)
])



if __name__ == "__main__":
    app.run_server(host='0.0.0.0',port=8050, debug=True)

To those who are try to do the same thing, I learned that I need specify a sourcelayer, of which there are many. I found them listed here.

Going to take some time to port this over to a mapbox spec. Wish this was easier, but I guess that is what raster tiles are for.

Hey. Did you ever get that to work? what portion of the text that you referenced did you have to use as β€œsourcelayer”?
Thanks

1 Like