示例
创建一个方形的规矩,并让点按轨迹移动。效果如下:
源代码
<template>
<div>
<div id="map" class="map"></div>
<button id="start-animation" ref="startButton">Start Animation</button>
</div>
</template>
<script>
import "ol/ol.css";
import "@/assets/css/map.css";
import {
Map, View, Feature } from "ol";
import {
Circle as CircleStyle, Fill, Icon, Stroke, Style } from "ol/style";
import {
OSM, Vector as VectorSource } from "ol/source";
import {
Tile as TileLayer, Vector as VectorLayer } from "ol/layer";
import {
getVectorContext } from "ol/render";
import {
LineString, Point } from "ol/geom";
import {
ref } from "vue";
export default {
setup(props) {
const map = ref(null);
const startButton = ref(null);
const styles = {
route: new Style({
stroke: new Stroke({
width: 6,
color: [237, 212, 0, 0.8],
}),
}),
icon: new