jwass / geojsonio.py

Open GeoJSON data on geojson.io
BSD 2-Clause "Simplified" License
121 stars 25 forks source link

geojsonio.embed redirects me to geojson.io instead of embedding an Iframe in the notebook. #6

Open wroscoe opened 7 years ago

wroscoe commented 7 years ago

I'm trying to embed a map in my Jupyter notebook. When I try to run the geojsonio.embed(geojson) function, the browser window is redirected to the geojson.io site. However when I embed any other site in an Iframe, it works fine.

This try's to redirect me.

import geojsonio, json

geojson = { "type": "FeatureCollection",
            "features": [
              { "type": "Feature",
                 "geometry": {
                   "type": "Polygon",
                   "coordinates": [
                     [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
                       [100.0, 1.0], [100.0, 0.0] ]
                     ]
                 },
                 "properties": {
                   "prop0": "value0",
                   }
                 }
               ]
             }

#redirects me to a geojsonio site
url = geojsonio.embed(json.dumps(geojson))

Using another URL the iframe functionality works as expected.

from IPython.display import IFrame 
url0 = 'http://donkeycar.com'
IFrame(url, width='100%', height=500)  
aubreymoore commented 6 years ago

I have the same problem.

jwass commented 6 years ago

I can reproduce this. After trying to fix it, I think it's something with geojson.io and there might not be anything we can do from the Python side to get it to embed properly.

Creating a very simple webpage with geojson.io in an iframe demonstrates this.

<!DOCTYPE html>
<html>
  <head>
    <title>Test IFrame</title>
  </head>
  <body>
    <iframe src="http://geojson.io" height="400" width="100%"></iframe>
    Some content here
  </body>
</html>
jwass commented 6 years ago

After digging into this a bit, this is the relevant commit to geojson.io which disables iframes: https://github.com/mapbox/geojson.io/commit/1a2f825047a78519b86941292a29b551314944d8