Created
July 10, 2015 22:24
-
-
Save BibMartin/0d298c07ebbf7048ca3d to your computer and use it in GitHub Desktop.
Embed folium map in an iframe for jupyter nb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.display import HTML | |
def _repr_html_(self, figsize=(17,10), **kwargs): | |
"""Displays in the notebook a folium.folium.Map object. | |
""" | |
self._build_map(**kwargs) | |
width, height = figsize | |
iframe = '<iframe src="data:text/html;base64,{html}" width="{width}" height="{height}"></iframe>'\ | |
.format(html = self.HTML.encode('base64'), | |
width = int(60.*width), | |
height= int(60.*height), | |
) | |
return HTML(iframe) |
I assume that self refers to the folium map. So i did _repr_html(my_folium_map) but it shows that 'Map' object has no attribute '_build_map'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you explain a little bit how to use the code? What should be the self? And what should be **kwarges? I am having the issue of folium map doesn't get displayed on github and maps disappear on consecutive reconnections to the same notebook. Thank you!