How can i view an html output file from a gmplot draw command inside of a Google Colab notebook?

Viewed 1551

I am trying to use colab and googlemaps to display a heatmap image overlayed onto google maps. I did some research and found 2 possible solutions at this link but both solutions are not working.

Display / Render an HTML file inside Jupyter Notebook on Google Colab platform

Maybe something has changed recently? Here is my code:

pip install gmplot
import gmplot 
gmap1 = gmplot.GoogleMapPlotter(30.3164945, 
                                78.03219179999999, 13, apikey='AIzaSyBCyhpxDYIxIq9uINYxDK5aIjWSokUvsvY' ) 
gmap1.draw( "map11.html" ) 
import os
print(os.getcwd())
!ls

/content
map11.html  sample_data

import IPython
IPython.display.HTML(filename='/content/map11.html')

nothing is displayed. 

from IPython.display import IFrame
IFrame(src='/content/map11.html', width=900, height=600)

localhost refused to connect.

enter image description here

1 Answers

Your local browser cannot read a file from the remote VM filesystem. Instead of passing the HTML by filename, try displaying the HTML content directly:

IPython.display.HTML(open('/content/map11.html').read())
Related