j.buchtaesri-de-esridist

Try it live - Basemap garbled (Description and Solution)

Discussion created by j.buchtaesri-de-esridist Employee on Apr 11, 2017
Latest reply on Apr 12, 2017 by bmajor-esristaff

Just in case, anyone trying the most basic sample and seeing a corrupt basemap, here's an explanation and the solution.

 

Steps to reproduce

  1. Use a recent version of Chrome or Firefox (other browsers not tested)
  2. Navigate to https://notebooks.esri.com 
  3. Create a new notebook (New -> Python 3)
  4. Enter the following script code
  5. from arcgis.gis import *
    gis = GIS()
    gis.map()
  6. Run the cell (<Ctrl-Enter>)
  7. The result looks similar to this:
  8. ArcGIS API for Python - Broken Basemap

 

 

Explanation

The notebook is running on an https (secured) connection. However, as we didn't authenticate to ArcGIS Online, we're getting the tiles (and some .js-code) from an http (non-secured) connection. Chrome and Firefox block that unsecured JavaScript code.

 

Workaround 1

Instead of using the secured https connection, use http://notebooks.esri.com instead. As everything will be loaded without encryption, Chrome / Firefox are happy with that.

However: If you change your script to an authenticated AGOL-Session, you will send your username / password in plain-text through the net!

 

Workaround 2

Both Chrome and Firefox have the option to explicitly allow loading unsecure content. In Chrome, there's a small icon on the right, in Firefox, it's right beside the https-indicator. 

Outcomes