Animate camera around point

Animate map camera around a point
This source code of this example is adapted from the MapLibre GL JS example - Animate map camera around a point.
Uncomment the following line to install leafmap if needed.
| # %pip install "leafmap[maplibre]"
|
| import time
import leafmap.maplibregl as leafmap
|
To run this notebook, you will need an API key from MapTiler. Once you have the API key, you can uncomment the following code block and replace YOUR_API_KEY with your actual API key. Then, run the code block code to set the API key as an environment variable.
| # import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 | m = leafmap.Map(center=[-87.62712, 41.89033], zoom=15, pitch=45, style="streets")
layers = m.get_style_layers()
for layer in layers:
if layer["type"] == "symbol" and ("text-field" in layer["layout"]):
m.remove_layer(layer["id"])
layer = {
"id": "3d-buildings",
"source": "composite",
"source-layer": "building",
"filter": ["==", "extrude", "true"],
"type": "fill-extrusion",
"min_zoom": 15,
"paint": {
"fill-extrusion-color": "#aaa",
"fill-extrusion-height": [
"interpolate",
["linear"],
["zoom"],
15,
0,
15.05,
["get", "height"],
],
"fill-extrusion-base": [
"interpolate",
["linear"],
["zoom"],
15,
0,
15.05,
["get", "min_height"],
],
"fill-extrusion-opacity": 0.6,
},
}
m.add_layer(layer)
m
|
| for degree in range(0, 360, 1):
m.rotate_to(degree, {"duration": 0})
time.sleep(0.1)
|
