If you're working in jupyterlab, this is pretty easy! You can combine a ipywidgets.Output
widget with a ipywidgets.Dropdown
to set up your canvas, then capture the follium map with the output. You then need to link them by adding an event handler.
import geopandas as gpd
import ipywidgets
from IPython.display import HTML, display
df = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
out = ipywidgets.Output(layout={'border': '1px solid black'})
w = ipywidgets.Dropdown(
options=df.columns.values.tolist(),
value=df.columns.values[0],
description='Column:',
disabled=False,
)
def on_dropdown_change(change):
out.clear_output()
with out:
display(df.explore(w.value, cmap="Blues"))
w.observe(on_dropdown_change, names='value')
display(w)
with out:
display(df.explore(df.columns[0], cmap="Blues"))
out
