Atlaslog
Atlaslog / MapLibre GL JS / Tutorial / Camera and view control
MapLibre GL JS · Tutorial

Camera and view control

Quick answer

This tutorial explains how MapLibre GL JS moves the camera with four methods: jumpTo for instant changes, easeTo for eased transitions, flyTo for parabolic long-distance flights, and fitBounds for framing an extent. It covers the duration, curve, essential, padding, maxZoom and offset options, plus how animations end, get cancelled, and drive per-frame rotation. After reading it you can script reliable view changes and keep overlays unobstructed.

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
Key points
Example
map.jumpTo({ center: [116.391263, 39.907359], zoom: 11 });
map.easeTo({
  center: [116.407000, 39.899000],
  duration: 800,
  easing: function (t) { return t * (2 - t); }
});
map.flyTo({
  center: [121.473701, 31.230416],
  zoom: 12,
  bearing: 0,
  pitch: 35,
  duration: 3600,
  curve: 1.4,        // 路径弯曲程度,越大越「高飞」
  essential: true    // 用户开启减少动效时仍然执行
});
var bounds = [
  [116.20, 39.80],      // 西南
  [116.55, 40.05]       // 东北
];

map.fitBounds(bounds, {
  padding: { top: 40, bottom: 120, left: 320, right: 40 },
  maxZoom: 15,
  duration: 1200
});
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Camera and view control. https://www.jingweizhi.com/en/maplibre/tutorials/camera-animation.html (accessed 2026-11-03).