Restrict bounds
Restrict map panning to an area
This source code of this example is adapted from the MapLibre GL JS example - Restrict map panning to an area .
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [ ]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [ ]:
Copied!
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
In [ ]:
Copied!
bounds = [
[-74.04728500751165, 40.68392799015035],
[-73.91058699000139, 40.87764500765852],
]
bounds = [
[-74.04728500751165, 40.68392799015035],
[-73.91058699000139, 40.87764500765852],
]
In [ ]:
Copied!
m = leafmap.Map(center=[-73.9978, 40.7209], zoom=13, max_bounds=bounds, style="streets")
m
m = leafmap.Map(center=[-73.9978, 40.7209], zoom=13, max_bounds=bounds, style="streets")
m
