demo源码运行环境以及配置

运行环境:依赖Node安装环境,需要安装Node。 运行工具:vscode或者其他工具。
配置方式:下载demo源码,vscode打开,然后顺序执行以下命令:
(1)下载demo环境依赖包命令:npm install -g
(2)yarn install
(3)启动demo命令:yarn dev
(4)打包demo命令: yarn build:prod

示例效果
在这里插入图片描述
实现思路

使用模拟数据线图层geojson,获取线的点集合数据,然后点和点之间直线插值点,获取到插值点数据集,最后结合arcgis api
4实现达到轨迹点模拟圆滑移动效果。

核心部分代码

<template><div id="viewDiv"></div><div class="titleContainer center"><span>vue3+arcgisAPI4示例:轨迹点模拟移动效果</span></div><el-button type="primary" class="buttonRight btn1" @click="starBtn">开始模拟</el-button><el-button type="primary" class="buttonRight btn2" @click="clearBtn">清除模拟</el-button>
</template>
<script setup>
import { onMounted, onUnmounted, ref } from "vue";
import "@arcgis/core/assets/esri/themes/light/main.css";
import Map from "@arcgis/core/Map";
import MapView from "@arcgis/core/views/MapView";
import Basemap from "@arcgis/core/Basemap.js";
import esriConfig from "@arcgis/core/config";
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer.js";
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
import GroupLayer from "@arcgis/core/layers/GroupLayer.js";
import Graphic from "@arcgis/core/Graphic.js";
import Point from "@arcgis/core/geometry/Point.js";
import { distance } from "@arcgis/core/geometry/geometryEngine.js";
import { geographicToWebMercator } from "@arcgis/core/geometry/support/webMercatorUtils.js";
import { removeElementById } from '@/utils/index';
import axios from "axios";
let view, map, graphicsLayer = null;
let animationFrameId = null; // 动画帧ID
let features = []; // 存储轨迹点
onMounted(() => {initMap();
});
// 组件卸载时取消动画
onUnmounted(() => {if (animationFrameId) {cancelAnimationFrame(animationFrameId);animationFrameId = null;}
});
const initMap = () => {esriConfig.apiKey = 'AAPKca495ea263b64e44b61eaaecdbddebfcwEQjC8k8-6XGMrrXyCie6xzybboRl4REq-TwDQTm8Wz-8sL6REARz1wcm14Kq9ny';// 初始化创建地图对象const novaLayer = Basemap.fromId("arcgis-imagery-standard");map = new Map({// basemap: "satellite",basemap: novaLayer,});// 初始化创建视图view对象view = new MapView({container: "viewDiv",map: map,center: [111.69795926864639, 23.2026556059399],zoom: 15});// 去除logoview.ui.remove(["attribution", "zoom"]);// 监听视图view初始化加载完成执行view.when(function () {removeElementById('loader-wrapper');loadPointLineLayer();});
}
const loadPointLineLayer = async () => {// 使用axios请求获取GeoJSON数据const response = await axios.get("./src/views/carTrack/carTrackPoint.geojson");const geojsonData = response.data;features = geojsonData.features;// 创建GeoJSON图层,使用blob URL而不是文件URLconst blob = new Blob([JSON.stringify(geojsonData)], { type: "application/json" });const blobUrl = URL.createObjectURL(blob);let pointsLayer = new GeoJSONLayer({url: blobUrl})const response1 = await axios.get("./src/views/carTrack/carTrackLine.geojson");const geojsonData1 = response1.data;// 创建GeoJSON图层,使用blob URL而不是文件URLconst blob1 = new Blob([JSON.stringify(geojsonData1)], { type: "application/json" });const blobUrl1 = URL.createObjectURL(blob1);let lineLayer = new GeoJSONLayer({url: blobUrl1})const groupLayer = new GroupLayer({layers: [pointsLayer,lineLayer]});map.add(groupLayer);graphicsLayer = new GraphicsLayer({ id: 'graphicsLayer' });map.add(graphicsLayer);
}
const starBtn = () => {// 读取模拟车辆轨迹数据let points = [];// 取消可能存在的动画if (animationFrameId) {cancelAnimationFrame(animationFrameId);animationFrameId = null;}// 生成所有轨迹点for (let i = 0; i < features.length; i++) {const feature = features[i];if (i !== features.length - 1) {points = points.concat(getPointSAlongLine(feature, features[i + 1], 1))}else {points = points.concat(getPointSAlongLine(feature, feature, 1))}}// 使用requestAnimationFrame实现动画let currentIndex = 0;let lastTimestamp = 0;const frameInterval = 100; // 控制动画速度,相当于之前的100msconst animate = (timestamp) => {// 计算时间差if (!lastTimestamp) lastTimestamp = timestamp;const elapsed = timestamp - lastTimestamp;// 当经过的时间超过帧间隔时更新位置if (elapsed >= frameInterval) {lastTimestamp = timestamp;if (currentIndex < points.length) {refreshAlarmPoint(points[currentIndex]);currentIndex++;      // 继续动画animationFrameId = requestAnimationFrame(animate);} else {// 动画结束animationFrameId = null;}} else {// 如果时间间隔不够,继续等待animationFrameId = requestAnimationFrame(animate);}};// 启动动画animationFrameId = requestAnimationFrame(animate);
}
const clearBtn = () => {// 取消可能存在的动画if (animationFrameId) {cancelAnimationFrame(animationFrameId);animationFrameId = null;}if (graphicsLayer) {graphicsLayer.removeAll();}
}
// 刷新绘制实时报警点
const refreshAlarmPoint = (point) => {if (graphicsLayer) {graphicsLayer.removeAll();}// 创建节点圆圈符号const symbol = {type: "simple-marker",style: "circle",color: [255, 255, 255], // 白色填充size: 12,outline: {color: [66, 135, 245], // 蓝色边框width: 2}};const graphic = new Graphic({geometry: point,symbol: symbol});graphicsLayer.add(graphic);
}
/*** 计算起点和终点连线上距离起点指定距离的坐标点* @param {Array} startPoint - 起点坐标* @param {Array} endPoint - 终点坐标* @param {Number} dis- 距离起点的距离,单位:米* @returns {Array} - 计算得到的坐标点*/
……
</script>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/bicheng/91875.shtml
繁体地址,请注明出处:http://hk.pswp.cn/bicheng/91875.shtml
英文地址,请注明出处:http://en.pswp.cn/bicheng/91875.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Design Compiler:Milkyway库的创建与使用

相关阅读 Design Compilerhttps://blog.csdn.net/weixin_45791458/category_12738116.html?spm1001.2014.3001.5482 DC Ultra推出了拓扑模式&#xff0c;在综合时会对标准单元进行粗布局(Coarse Placement)并使用虚拟布线(Virtual Routing)技术计算互联延迟&#xff0c;关于拓…

嵌入式教学的云端革命:高精度仿真如何重塑倒车雷达实验与工程教育——深圳航天科技创新研究院赋能新一代虚实融合实训平台

一、嵌入式教学的困境与破局之道 在传统嵌入式系统教学中&#xff0c;硬件依赖始终是核心痛点。以“倒车雷达实验”为例&#xff0c;学生需操作STM32开发板、超声波传感器、蜂鸣器等硬件&#xff0c;面临设备损耗、接线错误、调试效率低等问题。更关键的是&#xff0c;物理硬件…

flutter-boilerplate-project 学习笔记

项目地址&#xff1a; https://github.com/zubairehman/flutter_boilerplate_project/tree/master 样板包含创建新库或项目所需的最小实现。存储库代码预加载了一些基本组件&#xff0c;例如基本应用程序架构、应用程序主题、常量和创建新项目所需的依赖项。通过使用样板代码…

集成电路学习:什么是CMSIS微控制器软件接口标准

CMSIS,即Cortex Microcontroller Software Interface Standard(Cortex微控制器软件接口标准),是由ARM公司与多家不同的芯片和软件供应商紧密合作定义的一个标准。该标准旨在为基于ARM Cortex处理器的微控制器提供一套与供应商无关的硬件抽象层,从而简化软件的开发、重用,…

由浅入深使用LangGraph创建一个Agent工作流

创建一个简单的工作流&#xff1a;Start ——> 节点1(固定输入输出) ——> Endfrom langchain_core.messages import SystemMessage, HumanMessage, AIMessage from langgraph.graph import StateGraph, START, END from typing_extensions import TypedDict from typing…

PL-0功能拓展及基于VSCode的IDE配置

title: PL/0功能拓展及基于VSCode的IDE配置 date: 2024-08-06 22:46:38 tags: 做过的实验||项目复盘 top: true 概述PL/0语言可以看成PASCAL语言的子集,它的编译程序是由C语言编写的编译解释执行系统。PL/0能充分展示高级语言的最基本成分。拓展了pl0语言的基础功能&#xff08…

【低空经济】大型露天矿区安全生产无人机巡查与管理系统设计

1. 引言 大型露天矿区因其广阔的作业区域和复杂的环境条件&#xff0c;安全生产管理面临着严峻的挑战。随着科技的进步&#xff0c;无人机作为一种现代化的巡查工具&#xff0c;逐渐被应用于矿区的安全生产管理中。无人机具备高效、灵活、成本相对低廉等优点&#xff0c;可以在…

SpringCloud学习第一季-3

目录 11.服务网关-Gateway新一代网关 一、Gateway概述 1、Gateway是什么 1.1 概述 2、 能干嘛 3、微服务架构中网关在哪里 4、为什么选择gateway? 4.1 SpringCloud Gateway具有如下特性 4.2 SpringCloud Gateway 与 Zuul的区别 5、Zuul1.x模型 6、gateway模型 二、…

超越边界:MongoDB 16MB 文档限制的 pragmatic 解决方案

在软件开发中&#xff0c;我们选择的技术栈往往带有一些固有的设计边界。对于 MongoDB 而言&#xff0c;其最著名的边界之一便是 BSON 文档最大 16MB 的大小限制。在大多数场景下&#xff0c;这个限制是绰绰有余的&#xff0c;它鼓励开发者设计更为精简和规范的数据模型。然而&…

深入探讨:PostgreSQL正则表达式中的邮政编码匹配

引言 在处理大量数据时,如何高效地从字符串中提取特定模式的文本,如邮政编码,是一个常见且具有挑战性的任务。本文将通过一个具体实例,探讨在PostgreSQL中使用正则表达式匹配加拿大邮政编码的问题,并提供解决方案。 问题描述 我们希望能够从字符串中提取所有符合加拿大…

集合框架(重点)

第十五天集合框架1.什么是集合 Collections集合Collection&#xff0c;也是一个数据容器&#xff0c;类似于数组&#xff0c;但是和数组是不一样的。集合是一个可变的容器&#xff0c;可以随时向集合中添加元素&#xff0c;也可以随时从集合中删除元素。另外&#xff0c;集合还…

深度学习核心:神经网络-激活函数 - 原理、实现及在医学影像领域的应用

&#x1f9d1; 博主简介&#xff1a;CSDN博客专家、CSDN平台优质创作者&#xff0c;高级开发工程师&#xff0c;数学专业&#xff0c;10年以上C/C, C#,Java等多种编程语言开发经验&#xff0c;拥有高级工程师证书&#xff1b;擅长C/C、C#等开发语言&#xff0c;熟悉Java常用开发…

OneCode3.0 核心表达式技术深度剖析:从架构设计到动态扩展

一、引言&#xff1a;表达式技术在企业级框架中的核心价值 在当今快速变化的企业级应用开发中&#xff0c;动态性和灵活性已成为衡量框架优劣的关键指标。OneCode 3.0 框架作为企业级应用开发的重要工具&#xff0c;其核心表达式技术提供了一种强大的解决方案&#xff0c;使开发…

[css]旋转流光效果

实现一个矩形的旋转流光边框效果。 需要使用css属性梯度渐变&#xff1a;链接: conic-gradient&#xff0c;他指的是圆锥形变化的梯度。 // html<div class"demo"></div>// css body {width: 100%;height: 100%;background-color: black; }.demo {width…

NPM组件 @0xme5war/apicli 等窃取主机敏感信息

【高危】NPM组件 0xme5war/apicli 等窃取主机敏感信息 漏洞描述 当用户安装受影响版本的 0xme5war/apicli 等NPM组件包时会窃取用户的主机名、用户名、工作目录、IP地址等信息并发送到攻击者的电报地址(botToken “7699295118:AAF6pb7t718vjHWHwFQlZOastZQYHL8IVDE”&#x…

计算机网络:组播和多播有什么区别?

在网络通信中&#xff0c;“组播”和“多播”其实是同一概念的不同中文翻译&#xff0c;它们对应的英文都是 Multicast。二者本质上没有技术区别&#xff0c;只是因翻译习惯不同而产生的两种表述&#xff0c;在实际应用中可以通用。 不过&#xff0c;为了更清晰地理解这个概念&…

Amazon Q Developer:AI 增强编码生产力的未来

Amazon Q Developer&#xff1a;重塑编码体验的 AI 助手 在如今快节奏的软件开发世界中&#xff0c;开发者们始终在寻找能平衡生产力与探索欲的工具。而 Amazon 推出的 Amazon Q Developer&#xff0c;这款可嵌入 Visual Studio Code 等主流 IDE 的 AI 编码助手&#xff0c;无疑…

linux eval命令的使用方法介绍

在这篇文章中&#xff0c;让我们来详细地介绍一下 Linux 中另一个非常强大但也极其危险的命令&#xff1a;eval。 eval 是一个 shell 内置命令&#xff0c;它的名字是 “evaluate”&#xff08;评估&#xff09;的缩写。它的作用是将紧跟其后的参数&#xff08;一个或多个字符串…

JavaWeb笔记2-JavaScriptVueAjax

1. JavaScript 1.1 基础介绍 JavaScript(简称&#xff1a;JS)是一门跨平台、面向对象的脚本语言&#xff0c;是用来控制网页行为&#xff0c;实现页面的交互效果。JavaScript和Java是完全不同的语言&#xff0c;但基本语法类似组成 ECMAScript: 规定了JS基础语法核心知识&…

代码随想录刷题Day23

右旋字符串 这道题是比较常规的对字符串的复制操作&#xff0c;找到右旋部分的分界点是关键 代码直接贴出来&#xff1a; #include<stdio.h> #include<string.h> int main(){int k;char s[10000];scanf("%d %s",&k,s);int cnt 0;for(int i str…