#!/usr/bin/env python # coding: utf-8 # [![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/animate_camera_around_point.ipynb) # [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/animate_camera_around_point.ipynb) # [![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD) # # **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](https://maplibre.org/maplibre-gl-js/docs/examples/animate-camera-around-point/). # # Uncomment the following line to install [leafmap](https://leafmap.org) if needed. # In[ ]: # %pip install "leafmap[maplibre]" # In[ ]: import time import leafmap.maplibregl as leafmap # To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). 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. # In[ ]: # import os # os.environ["MAPTILER_KEY"] = "YOUR_API_KEY" # In[ ]: 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 # In[ ]: for degree in range(0, 360, 1): m.rotate_to(degree, {"duration": 0}) time.sleep(0.1) # ![](https://i.imgur.com/odCwtjT.png)