"MapboxGL Basics" - zoom in/zoom out/positioning/level

center point

getCenter : Get the center point

const {lng, lat} = map.getCenter();

setCenter : set the center point

// lng, lat
map.setCenter([134, 28]);

zoom level

  getZoom : Get the current zoom level

map.getZoom();

  setZoom : set the zoom level

map.setZoom(5);

  zoomTo : Zooms the texture to the specified zoom level using an animated transition

map.zoomTo(8, {
  duration: 2000,
  offset: [100, 50]
});

  zoomIn : zoom in

map.zoomIn({duration: 1000});

  zoomOut : zoom out

map.zoomOut({offset: [80, 60]});

position

jumpTo : jump

map.jumpTo({
  center: [0, 0],
  zoom: 8,
  pitch: 45,
  bearing: 90
});

flyTo : fly to

map.flyTo({
  center: [0, 0],
  zoom: 9,
  speed: 0.2,
  curve: 1,
  easing(t) {
   return t;
  }
});

easeTo : Changes any combination of center, scale, orientation, pitch, and fill with an animated transition between the old and new values. For any details not specified in the options, the map will retain its current value.

map.easeTo({
  center: [0, 0],
  zoom: 9,
  speed: 0.2,
  curve: 1,
  duration: 5000,
  easing(t) {
   return t;
  }
});

Guess you like

Origin blog.csdn.net/sinat_31213021/article/details/132024039