Plotly actually tries to retrieve data from https://cdn.plot.ly/world_110m.json to plot the map. I found discussions about this on python - Displaying Plotly maps on disconnected system - Stack Overflow, (Kevin Daly’s answer), and here Cannot draw a map offline · Issue #514 · plotly/plotly.py · GitHub (carlosvega’s answer)
Hammy27 suggested that installing plotly-geo would fix the issue, but it didnt work; maps are still missing.
The root of the issue is that the machine on which the dash app run does not have any access to the internet.
Edit:
While looking for a reference to “topojson” somewhere in the doc, in the modules files and on this forum, I found this previous post:
which pointed to the doc:
and helped a lot in fixing the problem. Thanks, @zoohair
In a nutshell, the solution consists in:
-
in the DashApp assets folder, make a new folder in which will be stored the topjson files. In this example, I named it “topojson_local”
-
copy-paste the content of https://cdn.plot.ly/world_110m.json, https://cdn.plot.ly/world_110m.json in a json file, which is then saved into the assets/topojson folder. Proceed similarly with https://cdn.plot.ly/world_50m.json, and the other ones.
-
at the top of the dash app, add the following:
isOffline = True plotlyConfig = {'topojsonURL':'assets/topojson_local/'} if isOffline else {}
(as suggested by @zoohair )
-
the dcc.Graph component containing the map must set the config arg as below:
dcc.Graph( id='map-xyz', config=plotlyConfig, figure=fig, style={"height": "100%"} )
And then, the dash app will render the map, even if it is executed on some intranet without any access to the web.