vue是否可以做行车轨迹_Vue + Openlayers 自定义轨迹动画

本文展示了如何利用Vue结合OpenLayers库创建行车轨迹动画。通过初始化地图,设置坐标点,绘制路线并实现线的动态移动,来模拟行车轨迹。文章提供了详细代码示例,包括设置地图、矢量图层、线样式以及开始和停止动画的方法。
摘要由CSDN通过智能技术生成

href="https://openlayers.org/en/latest/examples/feature-move-animation.html?q=polyline"

target="_bank"

>OpenlayersTrack

{ {progress}}%

运动速度: 

{ {textContent}}

import "ol/ol.css";

import Feature from "ol/Feature";

import Map from "ol/Map";

import View from "ol/View";

import Polyline from "ol/format/Polyline";

import { Projection } from "ol/proj";

import { Point, LineString } from "ol/geom";

import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer";

import XYZ from "ol/source/XYZ";

import VectorSource from "ol/source/Vector";

import {

Circle as CircleStyle,

Fill,

Icon,

Stroke,

Style,

Text

} from "ol/style";

import { getVectorContext } from "ol/render";

export default {

data() {

return {

map: null,

progress: 0, // 进度

animating: false, // 动画是否开始

speed: null, // 速度

now: null, // 当前时间

textContent: "开始",

routeCoords: null, // 数组点集合

routeLength: null, // 数组长度

route: null, // 线

routeFeature: null, // 画线

geoMarker: null, // 标记

startMarker: null, // 开始标记

endMarker: null, // 结束标记

styles: {

route: new Style({

// 线的样式

stroke: new Stroke({

width: 6,

color: [237, 212, 0, 0.8]

})

}),

icon: new Style({

// 默认icon样式

image: new CircleStyle({

radius: 7,

fill: new Fill({ color: "red" }),

stroke: new Stroke({

color: "white",

width: 2

})

})

}),

geoMarker: new Style({

// 设置标记样式

image: new Icon({

anchor: [0.5, 1], // 偏移位置

// rotation: 0, // 旋转

// size: [52, 26], // 图标大小

src: require("@/assets/tx-

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值