How to show gmaps object (from Google Maps api) on streamlit

Hi everyone,

I am trying to display the map given by Google Maps API using python gmaps library on streamlit. I know that there are other ways to plot maps like folium or with st.map but I would like to use directly the google maps one. Notebook example:

The map object is of type gmaps.figure.Figure so it’s not a standard one. Does anyone have any idea on how to display it?

Hi @AelxRossi, welcome to the Streamlit community!

From a quick reading of the gmaps source code, it looks like they might be doing this via a ipywidgets display. If so, that’s not currently able to be embedded within Streamlit.

Best,
Randy

1 Like

Hey @randyzwitch thanks for your reply :slight_smile:

In this discussion about pywidgets I found this solution that seems to do the job.
ipywidgets streamlit discussion

from ipywidgets import embed
snippet = embed.embed_snippet(views=map)
html = embed.html_template.format(title="", snippet=snippet)

import streamlit.components.v1 as components
components.html(html, height=500,width=500)
1 Like

Perfect, thanks for surfacing that!

1 Like