Skip to content

Instantly share code, notes, and snippets.

@BibMartin
Created July 10, 2015 22:24
Show Gist options
  • Save BibMartin/0d298c07ebbf7048ca3d to your computer and use it in GitHub Desktop.
Save BibMartin/0d298c07ebbf7048ca3d to your computer and use it in GitHub Desktop.
Embed folium map in an iframe for jupyter nb
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)
@melissaUMD
Copy link

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