Jump to a series of locations
This source code of this example is adapted from the MapLibre GL JS example - Jump to a series of locations.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import time
import leafmap.maplibregl as leafmap
import time
import leafmap.maplibregl as leafmap
In [3]:
Copied!
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
In [4]:
Copied!
m = leafmap.Map(center=[100.507, 13.745], zoom=9, style="streets")
cities = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [100.507, 13.745]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [98.993, 18.793]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [99.838, 19.924]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [102.812, 17.408]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [100.458, 7.001]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [100.905, 12.935]},
},
],
}
m
m = leafmap.Map(center=[100.507, 13.745], zoom=9, style="streets")
cities = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [100.507, 13.745]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [98.993, 18.793]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [99.838, 19.924]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [102.812, 17.408]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [100.458, 7.001]},
},
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [100.905, 12.935]},
},
],
}
m
Failed to retrieve the MapTiler style. Defaulting to 'dark-matter' style.
In [5]:
Copied!
for index, city in enumerate(cities["features"]):
time.sleep(2)
coords = city["geometry"]["coordinates"]
m.jump_to({"center": coords})
for index, city in enumerate(cities["features"]):
time.sleep(2)
coords = city["geometry"]["coordinates"]
m.jump_to({"center": coords})