leafmap: Zoom to location/layer

23 views Asked by At

I try to a leafmap python script in Jupyter with the possibility to zoom to a location given in a dropdown menu. To do so, I wrote the following code but unfortunately the map is not moved to the given coordinates.

import leafmap
from ipywidgets import Dropdown, VBox

m = leafmap.Map(center = [50, 12], zoom = 7)

coordinates = {'München': [48.1351, 11.5820], 'Berlin': [52.5200, 13.4050], 'Hamburg': [53.5511, 9.9937]}
dropdown = Dropdown(options=coordinates, description='Select location:')

def update_map(change):
    center_coords = dropdown.value
    m.center = center_coords

dropdown.observe(update_map, names='value')

VBox([dropdown,m])

How can I implement such a feature? Thank you!

0

There are 0 answers