
Uncomment the following line to install leafmap if needed.
| # %pip install "leafmap[maplibre]"
|
| import leafmap.maplibregl as leafmap
|
1
2
3
4
5
6
7
8
9
10
11
12
13 | m = leafmap.Map(
center=[-100, 40], zoom=2, style="liberty", sidebar_visible=True, projection="globe"
)
m.add_basemap("USGS.Imagery")
states_url = (
"https://github.com/opengeos/datasets/releases/download/us/us_states.geojson"
)
m.add_geojson(states_url, name="US States", fit_bounds=False)
cities_url = (
"https://github.com/opengeos/datasets/releases/download/world/world_cities.geojson"
)
m.add_geojson(cities_url, name="World Cities", fit_bounds=False)
m
|
| import ipywidgets as widgets
|
| zoom_slider = widgets.FloatSlider(value=3, min=1, max=20, step=1, description="Zoom")
zoom_slider.observe(lambda change: m.set_zoom(change["new"]), names="value")
m.add_to_sidebar(zoom_slider, label="Zoom", widget_icon="mdi-magnify")
|
