@srepho’s solution works for me too.
By follow-up problem is changing this to read from a json file stored on my local machine rather than the url from Mapbox studio.
So the following works:
mapbox_access_token = ...
mapbox_style = 'mapbox://styles/...'
layout = dict(
autosize=True,
height=1000,
font=dict(color='black'),
titlefont=dict(color='black', size='14'),
margin=dict(l=35, r=35, b=35, t=45),
hovermode="closest",
mapbox=dict(
accesstoken=mapbox_access_token,
style=mapbox_style,
center=dict(lon=list(get_depot_lat_long(from_depot).lon)[0],
lat=list(get_depot_lat_long(from_depot).lat)[0]),
zoom=7
)
)
But after downloading the zip from Mapbox studio, un-zipping, checking the filepath to my ‘.json’ file and using the following logic instead, it no longer works:
import json
with open(path_to_map_style_json, 'r') as read_file:
map_style = json.load(read_file)
layout = dict(
autosize=True,
height=1000,
font=dict(color='black'),
titlefont=dict(color='black', size='14'),
margin=dict(l=35, r=35, b=35, t=45),
hovermode="closest",
mapbox=dict(
accesstoken=mapbox_access_token,
# style=mapbox_style,
center=dict(lon=list(get_depot_lat_long(from_depot).lon)[0],
lat=list(get_depot_lat_long(from_depot).lat)[0]),
zoom=7,
layers=dict(
sourcetype='geojson',
source=map_style
)
)
)
Any advice much appreciated!