ol-interaction-dragrotate
Rotate the map by clicking and dragging on the map, normally combined with an
ol/events/condition
that limits it to when thealt
andshift
keys are held down.
Demo
Setup
Plugin usage
This component is part of the Interactions
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 Interactions
plugin
ts
import { createApp } from "vue";
import App from "./App.vue";
import {
Map,
Layers,
Sources,
Interactions,
} from "vue3-openlayers";
const app = createApp(App);
// ...
app.use(Interactions);
// ...
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 Interactions
.
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 Usage | Explicit Import |
---|---|
<ol-interaction-dragrotate> | <Interactions.OlInteractionDragrotate> |
vue
<template>
<ol-map
:loadTilesWhileAnimating="true"
:loadTilesWhileInteracting="true"
style="height: 400px"
>
<ol-view
ref="view"
:center="center"
:zoom="zoom"
:projection="projection"
/>
<ol-tile-layer>
<ol-source-osm />
</ol-tile-layer>
<ol-interaction-dragrotate />
</ol-map>
</template>
<script setup>
import { ref } from "vue";
const center = ref([-102.13121, 40.2436]);
const projection = ref("EPSG:4326");
const zoom = ref(5);
</script>
Properties
condition
- Type:
Function
duration
- Type:
Number
- Default:
250