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

这篇博客介绍了如何使用Vue和OpenLayers库创建行车轨迹动画。通过实例代码,展示了如何初始化地图,设置轨迹坐标,以及实现动画效果,包括移动速度控制和标记显示。文章还提供了相关组件和样例代码。
摘要由CSDN通过智能技术生成

本文实例为大家分享了Vue+Openlayers实现轨迹动画的具体代码,供大家参考,具体内容如下

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], // 图标大小

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值