简体   繁体   中英

How do I display gmplot HTML inside jupyter lab notebook?

I am currently trying to get some HTML to display inside jupyter lab notebook using ipython. I have got a way to work, however it requires me pushing the html file to github for github pages and then rendering the link inside jupyter lab.

The code that works:

IFrame(src='https://aasnani.github.io/test/', width=900, height=600)

However, I am trying to get it to work locally without having to push the file to GitHub.

I have tried:

IPython.display.IFrame(src=base_path + 'MN_Map.html', width=900, height=600)
IPython.display.HTML(filename=base_path + 'MN_Map.html')
IFrame(src=base_path + 'MN_Map.html', width=900, height=600)

HtmlFile = open(base_path + 'MN_Map.html', 'r', encoding='utf-8')
source_code = HtmlFile.read() 
display(HTML(source_code))

And none of these work. I have also enabled the gmaps and nbextensions in jupyter lab. Can someone explain why the first method works but the others don't? You can get the html file from the github link itself here or from the repo here .

Thank you in advance!

Not a fundamental solution, but I found that this problem can be solved by using local server.

Example: launch server with Live Server , set http://127.0.0.1:5500/<FILENAME>.html as src

Plot google map in jupyter notebook with Life Server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM