当前位置: 首页 > news >正文

vue3-openlayers 轨迹回放(历史轨迹)(ol-animation-path实现)

本篇介绍一下使用vue3-openlayers轨迹回放(历史轨迹)(ol-animation-path实现)

1 需求

  • 轨迹回放(历史轨迹)
  • 实时轨迹

2 分析

  • 轨迹回放(历史轨迹),一般是一次性拿到所有坐标点,使用ol-animation-path可以直接实现

3 实现

<template><ol-map:loadTilesWhileAnimating="true":loadTilesWhileInteracting="true"style="width: 100%; height: 100%"ref="mapRef"><ol-view ref="view" :center="center" :zoom="zoom" :projection="projection" /><ol-tile-layer><ol-source-tianditulayerType="img":projection="projection":tk="key":hidpi="true"ref="sourceRef"></ol-source-tianditu></ol-tile-layer><ol-tile-layer><ol-source-tianditu:isLabel="true"layerType="img":projection="projection":tk="key":hidpi="true"></ol-source-tianditu></ol-tile-layer><ol-vector-layer><ol-source-vector><ol-feature ref="animationPath"><ol-geom-line-string :coordinates="data"></ol-geom-line-string><ol-style-flowlinecolor="rgba(228, 147, 87, 1)"color2="rgba(228, 64, 0, 1)":width="10":width2="10":arrow="1"/></ol-feature><ol-animation-pathref="pathRef"v-if="animationPath":path="animationPath?.feature":duration="4000":repeat="0":speed="0.005"><ol-feature><ol-geom-point :coordinates="data[0]"></ol-geom-point><ol-style :zIndex="10"><ol-style-icon :src="iconSrc" :width="30" :height="30" :rotation="angle"></ol-style-icon></ol-style></ol-feature></ol-animation-path></ol-source-vector></ol-vector-layer></ol-map>
</template><script setup lang="ts">
import iconSrc from '@/assets/image/truck.png';const center = ref([121, 31]);
const projection = ref('EPSG:4326');
const zoom = ref(5);
const mapRef = ref();
const key = '替换为天地图key';
const sourceRef = ref(null);
const animationPath = ref(null);
const pathRef = ref(null);
const data = ref([[110, 30],[110.2, 30],[110.4, 30.2],[110.8, 30.4],[111, 31],[111.3, 31],[111.6, 31],[111.9, 31],[112, 31],[112.3, 31],[112.5, 31],[112.8, 31],[113, 31],[114, 31],[115.3, 32],[115.5, 32],[115.8, 31.8],[116, 31.4],[116.2, 31.1],[116.5, 30.5],[115, 30.2],[114, 29.8],[113, 29.6],[112, 29.4],[111, 30.2],[110, 30.4],[109, 30.6],[108, 31]
]);
const angle = ref(0);
</script>
<style scoped lang="scss"></style>

speed不存在时会取duation的值(二者存一即可,都存在,speed优先)

4 总结

  • 动画比使用定时器丝滑
  • 拖拉机图标旋转角度不好根据path进行动态修改
http://www.lryc.cn/news/382945.html

相关文章:

  • 计算机视觉全系列实战教程 (十二):图像分割(阈值分割threshold、分水岭算法watershed的使用步骤、洪水填充floodFill算法的使用)
  • Linux的免交互
  • 查看es p12证书文件过期方法
  • 1.8 无符号大数加、减运算
  • Java常用类--包装类
  • SpringMvcの拦截器全局异常处理
  • JVM虚拟机的组成
  • 探索CSS clip-path: polygon():塑造元素的无限可能
  • 【华为OD机试B卷】单词接龙(C++/Java/Python)
  • 项目实训-vue(十七)
  • Android10 SystemUI系列 需求定制(二)隐藏状态栏通知图标,锁屏通知,可定制包名,渠道等
  • Linux:RAID磁盘阵列
  • MongoDB和AI 赋能行业应用:零售
  • MQ~消息队列能力、AMQP协议、现有选择(Kafka、RabbitMQ、RocketMQ 、Pulsar)
  • 开源网安参与编制的《代码大模型安全风险防范能力要求及评估方法》正式发布
  • 【树状数组 队列】1505. 最多 K 次交换相邻数位后得到的最小整数
  • 【附精彩文章合辑】当谈到程序的“通用性”与“过度设计”的困境时,我们可以通过一些具体的例子来更直观地阐述这些解决方案
  • Word中删除空白页
  • 30.Netty进阶-黏包半包解决方案-短链接
  • 斜堆(数据结构篇)
  • 河南大学24计算机考研数据,有三个学院招收计算机相关专业,都是考的408!
  • ubuntu离线安装docker导入镜像
  • 鸿蒙原生应用元服务开发-位置服务申请权限
  • 基于SpringBoot的“智慧食堂”管理系统设计与实现
  • 高效记录收支明细:揭秘如何通过曲线图精准分析每月开销
  • 开发注意事项
  • Vue79-路由组件独有的2个新的生命周期钩子
  • Lua博客网站支持搜索、评论、登录注册
  • BGP高级特性
  • 鸿蒙开发:1.环境搭建和入门