Skip to content

ol-rotate-control

A Rotate control for OpenLayers.

Demo

Setup

Plugin usage

This component is part of the MapControls plugin. If not installed globally, you need to import and use the plugin in your main.ts or use the explicit component import (see section below).

Import and use the MapControls plugin
ts
import { createApp } from "vue";
import App from "./App.vue";

import {

  Map,
  Layers,
  Sources,
  MapControls,
} from "vue3-openlayers";

const app = createApp(App);
// ...
app.use(MapControls); 
// ...

Explicit import

If you don't want to install a plugin, you can import the component explicitly. It's available as a child of the named export MapControls.

NOTE

The following documentation refers to the plugin usage. Please make sure to adopt the component names, when you decided to use explicit component imports (e. g. <ol-map> becomes <Map.OlMap> etc.).

Usage

Plugin UsageExplicit Import
<ol-rotate-control><MapControls.OlRotateControl>
vue
<template>
  <button class="btn-default" type="button" @click="rotateRight">
    Rotate right
  </button>
  <ol-map style="height: 400px" :controls="[]">
    <ol-view ref="viewRef" :center="center" :zoom="zoom" :rotation="rotation" />

    <ol-tile-layer>
      <ol-source-osm />
    </ol-tile-layer>
    <ol-rotate-control />
  </ol-map>
</template>

<script setup>
import { ref } from "vue";
const center = ref([14200000, 4130000]);
const zoom = ref(6);
const viewRef = ref(null);
const rotation = ref(Math.PI / 6);

function rotateRight() {
  viewRef.value?.adjustRotation(0.1);
}
</script>

Properties

className

  • Type: String
  • Default: ol-rotate

label

  • Type: String
  • Default:

tipLabel

  • Type: String
  • Default: Reset rotation

compassClassName

  • Type: String
  • Default: ol-compass

duration

  • Type: Number
  • Default: 250

autoHide

  • Type: Boolean
  • Default: false

render

  • Type: Function

resetNorth

  • Type: Function

target

  • Type: HTMLElement