Skip to content


A View object represents a simple 2D view of the map.

This is the object to act upon to change the center, resolution, and rotation of the map.

A View has a projection. The projection determines the coordinate system of the center, and its units determine the units of the resolution (projection units per pixel). The default projection is Spherical Mercator (EPSG:3857).


Example of simple map with view in EPSG:4326 projection. See also documentation of ol-map component

  <ol-map style="height: 400px">

      <ol-source-osm />


    <li>center : {{ currentCenter }}</li>
    <li>resolution : {{ currentResolution }}</li>
    <li>zoom : {{ currentZoom }}</li>
    <li>rotation : {{ currentRotation }}</li>

<script setup>
import { ref } from "vue";

const center = ref([40, 40]);
const projection = ref("EPSG:4326");
const zoom = ref(8);
const rotation = ref(0);

const currentCenter = ref(center.value);
const currentZoom = ref(zoom.value);
const currentRotation = ref(rotation.value);
const currentResolution = ref(0);

function resolutionChanged(event) {
  currentResolution.value =;
  currentZoom.value =;
function centerChanged(event) {
  currentCenter.value =;
function rotationChanged(event) {
  currentRotation.value =;

Props from OpenLayers

Properties are passed-trough from OpenLayers directly. Their types and default values can be checked-out in the official OpenLayers docs. Only some properties deviate caused by reserved keywords from Vue / HTML. This deviating props are described in the section below.

Deviating Properties


Rotation is enabled by default. Setting this to false prevents from any rotation even when the property rotation is set or by using methods such ad adjustRotation or setRotation.


You have access to all Events from the underlying source. Check out the official OpenLayers docs to see the available events tht will be fired.

<ol-view @error="handleEvent">
  <!-- ... -->


You have access to all Methods from the underlying source. Check out the official OpenLayers docs to see the available methods.

To access the source, you can use a ref() as shown below:

  <!-- ... -->
  <ol-view ref="viewRef" @error="handleEvent">
    <!-- ... -->
  <!-- ... -->

<script setup lang="ts">
import { ref, onMounted } from "vue";
import type View from "ol/View";

const viewRef = ref<{ view: View }>(null);

onMounted(() => {
  const view: View = viewRef.value?.view;
  // call your method on `view`