How to include mapbox_layers in .html file

45 Views Asked by At

Question: How can I include the mapbox_layers when downloading the plot to .html in jupyter notebook? The download only includes the geojson in the choropleth_mapbox.

Code:

fig = px.choropleth_mapbox(
    data_frame = df,
    geojson = A,                    
    featureidkey = 'properties.DGID',
    locations = 'DGUID',              
    mapbox_style = 'open-street-map',
    opacity = 0.60,
    center = dict(lat = 53.9171, lon = -120.7497),
    zoom = 6)

fig.update_layout(
     mapbox_layers = [
        {
            "below": 'traces',
            "sourcetype": "geojson",
            "type": "fill",
            "color": "rgba(200,255,255,0.45)",
            "source": 'b.geojson'
        }
    ],
    height = 500,
    width = 500,
)

fig.show()

plotly.offline.plot(fig, filename = 'test.html')

With the mapbox_layer before generating .html

enter image description here

Without the mapbox_layer after generating .html

enter image description here

0

There are 0 best solutions below