Atlaslog
Atlaslog / OpenLayers / API reference / View
OpenLayers · API reference

View

Quick answer

View is ol.View, the object holding center, zoom or resolution, rotation and projection that defines what the map shows. Configure center in view projection coordinates, zoom, minZoom and maxZoom, extent, padding, constrainResolution and enableRotation. Move the map with setCenter, setZoom, fit or animate instead of recreating the view.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
new ol.View( options )
Key points
Example
var view = new ol.View({
  center: ol.proj.fromLonLat([116.391263, 39.907359]),
  zoom: 12,
  minZoom: 4,
  maxZoom: 18
});

/* 缩放到一个矩形范围,留 40 像素边距并带过渡 */
view.fit([116.30, 39.85, 116.50, 39.98], {
  padding: [40, 40, 40, 40],
  duration: 600
});
var resolution = view.getResolution();
var metersPerPixel = resolution;      // EPSG:3857 下单位就是米

/* 反过来设一个固定分辨率,相当于锁定显示比例 */
view.setResolution(10);
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). View. https://www.jingweizhi.com/en/openlayers/api/view.html (accessed 2026-11-03).