Scattergeo loading map offline from local topojson (with Python) [Solved]

I’ve created a scattergeo plot with plotly offline & Python to be used in an offline html dashboard.

The plot uses the default world map; the topojson file “world_110m.json,” which is clearly retrieved from

  • I’ve downloaded the world_110m.json from
  • I’d like to place this .json in a folder “topojson,” in the same directory as the local html copy of my scattergeo plot in order for the map to load without an internet connection.

Does anyone have any idea how to achieve this?

I didn’t expect it to work; but so far I tried specifying the following in the plot configuration: {‘topojsonURL’:’./topojson/’}

With this method; opening the plot with chrome I get the following error messages in the browser console:

  • Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
  • Error: unexpected error while fetching topojson file at ./topojson/world_110m.json


Hi @davedoode,

You’ve got the right idea, the trouble is you’re running in to your browser’s same-origin policy, which prevents loading generic data files (like json) from the file system. The three.js project has nice page covering this concept and some ways to work around it (see

Basically you can open the html file using a webserver (not as involved as it may sound, you can do this using a single Python command) or change your browsers security settings.

Hope that helps!

Thanks Jon, your advice pointed me in the right direction. It was the same origin policy blocking me.

My solution goes a bit off topic but hopefully will help others.

In the end I rolled my dashboard into a node-webkit app and disabled Chromium’s same origin policy with the following line in my app manifest file:

"chromium-args": "--allow-file-access-from-files --allow-file-access --user-data-dir"

The line in the html output should be:
"topojsonURL": process.cwd() + "\\files\\topojson\\"

To prevent “process.cwd()” being added as a string value I did the following in Python:

html_plt = plot(fig, output_type='div', config={'topojsonURL': '*process.cwd()*' + '\\' + 'files\\topojson\\'})
html_plt = html_plt.replace('"*process.cwd()*', 'process.cwd() + "')

I then just wrote “html_plt” out as a html file.

Loads fine without a connection or server :slightly_smiling_face:

1 Like

Hi @davedoode, i’m looking for ways you can load custom topojson file into plotly. Wondering how you do that. Would you mind to share how?

Thank you.

did you ever figure this out?