轨迹巡查分为俯瞰和跟随两种模式

<template><div><div @click="onClick">{{ info.name }}</div><div id="track-content" v-show="widgetShow"><a-button-group><a-button icon="caret-right" @click="startTrack" v-if="!onTrack"/><a-button icon="pause" @click="stopTrack" v-else/><a-button @click="changeViewModel">{{ fullScale?'跟随':'俯瞰' }}</a-button></a-button-group></div><a-modaltitle="选择轨迹":visible="visible"><template slot="footer"><a-button key="back" @click="handleCancel">取消</a-button></template><a-list><a-list-item v-for="item in trackList" :key="item.id" @click="chooseTrack(item)"><a>{{ item.mc }}</a></a-list-item></a-list></a-modal></div>
</template><script>
import Point from '@arcgis/core/geometry/Point'
import Graphic from '@arcgis/core/Graphic'
import Polyline from '@arcgis/core/geometry/Polyline'
import { trackinspectionlist, transferdictlist } from '@/api/manage'export default {props: {info: {type: Object,default() {return { name: '轨迹巡查', url: '' }}}},name: 'TrackInspection',data() {return {prevLocation: 0,location: 0,onTrack: false,view: 0,fullScale: false,visible: false,pos: 0,trackList: [],trackData: [],widgetShow: false}},mounted() {transferdictlist({ parent: 'GJXC', enable: true }).then(res => {this.trackList = res.data})},methods: {stopTrack() {this.onTrack = false},startTrack() {this.onTrack = truethis.doTrack(this.pos)},changeViewModel() {this.fullScale = !this.fullScale},onClick() {window.trackInspection = thisthis.widgetShow = truethis.view = window.viewthis.pos = 0if (this.trackList.length === 0) {this.$message.warn('请先维护轨迹数据')} else if (this.trackList.length === 1) {this.chooseTrack(this.trackList[0])} else {this.visible = !this.visible}},doTrack(pos) {if (this.onTrack) {this.location = new Point({x: parseFloat(this.trackData[pos].longitude),y: parseFloat(this.trackData[pos].latitude),z: parseFloat(this.trackData[pos].height),spatialReference: {wkid: window.arcgisData.coordinatesystem}})const textSymbol = {type: 'text',color: 'white',haloColor: 'black',haloSize: '1px',text: this.trackData[pos].remark,xoffset: 60,yoffset: 3,font: {size: 12,family: 'Josefin Slab',weight: 'bold'}}var graphic = new Graphic({geometry: this.location,symbol: this.view.getDrawSymbol('point')})if (pos > 0) {// this.view.graphics.removeAt(this.view.graphics.length - 1)// this.view.graphics.removeAt(this.view.graphics.length - 2)this.view.graphics.remove(graphic)}this.polylineJson = {'paths': this.trackData.slice((pos === 0 ? 0 : pos - 1), pos + 1).map(ele => {return [parseFloat(ele.longitude), parseFloat(ele.latitude), parseFloat(ele.height)]}),'spatialReference': { 'wkid': window.arcgisData.coordinatesystem }}var polyline = new Polyline(this.polylineJson)var symbol = {type: 'simple-line',color: '#10d5ef',width: 8}var graphic3 = new Graphic({geometry: this.location,symbol: textSymbol})const graphic1 = new Graphic(polyline, symbol)window.view.graphics.add(graphic1)this.view.graphics.add(graphic)this.view.graphics.add(graphic3) // 展示时间if (!this.fullScale) {this.view.goTo({center: this.location,tilt: 50,scale: window.view.scale,heading: 360 - this.getHeading(this.location, this.prevLocation), // only applies to SceneViewrotation: 360 - this.getHeading(this.location, this.prevLocation) // only applies to MapView})} else {let centerX = 0let centerY = 0this.trackData.forEach(ele => {centerX += parseFloat(ele.longitude) / this.trackData.lengthcenterY += parseFloat(ele.latitude) / this.trackData.length})const center = new Point({x: centerX,y: centerY,spatialReference: {wkid: window.arcgisData.coordinatesystem}})this.view.goTo({center: center,tilt: 0,scale: window.view.scale,heading: 360,rotation: 360})}this.prevLocation = this.locationif (pos === this.trackData.length - 1) {pos = 0this.view.graphics.removeAll()}setTimeout(() => {this.doTrack(++pos)}, 1000)} else {this.pos = pos}},getHeading(location, prevLocation) {const angleInDegrees = (Math.atan2(location.y - prevLocation.y, location.x - prevLocation.x) * 180) / Math.PI// move heading northreturn -90 + angleInDegrees},handleCancel() {this.visible = falsewindow.measureClear()},chooseTrack(item) {trackinspectionlist({ dict: item.dm }).then(res => {this.trackData = res.datathis.onTrack = truethis.prevLocation = new Point({x: parseFloat(this.trackData[this.trackData.length - 1].longitude),y: parseFloat(this.trackData[this.trackData.length - 1].latitude),spatialReference: {wkid: window.arcgisData.coordinatesystem}})this.view.goTo({center: this.prevLocation,tilt: 50,scale: 5000}).then(() => {this.doTrack(0)})this.visible = false})}}
}
</script><style>
#track-content {position: fixed;left: 15px;bottom: 90px;
}
</style>

效果图:

arcgis for JavaScript 使用view.goTo 实现轨迹巡查相关推荐

  1. ArcGis for javascript 绘制线!!!

    效果图 在线预览 前言 项目中需要使用 ArcGis 来实现地图功能,至于为什么不适用百度.高德,是因为据说 ArcGis 定位会准一点.初次接触 Arcgis for javascript,踩坑之路 ...

  2. ArcGIS For JavaScript API 默认参数

    "esri.config"的是在1.3版中的的"esriConfig"的替代品.如果您使用的是1.2或更低的版本,您应该参阅默认API v1.2和更低的配置.对 ...

  3. 利用Arcgis for javascript API绘制GeoJSON并同时弹出多个Popup

    1.引言 由于Arcgis for javascript API不可以绘制Geojson,并且提供的Popup一般只可以弹出一个,在很多专题图制作中,会遇到不少的麻烦.因此本文结合了两个现有的Arcg ...

  4. Arcgis for javascript不同的状态下自定义鼠标样式

    俗话说:爱美之心,人皆有之.是的,没错,即使我只是一个做地图的,我也希望自己的地图看起来好看一点.在本文,给大家讲讲在Arcgis for javascript下如何自定义鼠标样式. 首先,说几个状态 ...

  5. Arcgis for javascript不同的状态下自己定义鼠标样式

    俗话说:爱美之心.人皆有之. 是的.没错,即使我仅仅是一个做地图的,我也希望自己的地图看起来好看一点. 在本文,给大家讲讲在Arcgis for javascript下怎样自己定义鼠标样式. 首先.说 ...

  6. arcgis for javascript API3.13 加载天地图卫星影像

    采用arcgis for javascript  API 3.13, 用其中的esri.layers.TiledMapServiceLayer,这个类可以完成对切片地图的加载,ArcOnline本身自 ...

  7. 关于ArcGis for javascript整合百度地图 天地图 高德地图进行搜索

    1.ArcGis for javascript整合百度地图搜索 1.1.首先引入百度地图的api 1 <!-- 引入百度地图API --> 2 <script type=" ...

  8. Arcgis server Javascript API 官网相当于HelloWorld的完整版

    虽然放暑假了,不过最近依然很忙,一边忙着准备电子设计大赛,一边跟随研究生师兄们要做Arcgis相关内容,看了一本ArcGIS Server JavaScript API的书,结果发现是针对Arcgis ...

  9. Angular(4)中加载Arcgis for JavaScript地图

    背景 近期我司项目的需要,采用Angular(4)+SpringBoot前后端分离的架构.并且在需要在项目中实现Arcgis地图. 本人之前有过Arcgis for JavaScript的小小填坑经验 ...

最新文章

  1. 使用LS2J技术在LotusScript中使用Java
  2. TSP_遗传算法求解
  3. Intel Realsense 通过用户配置文件(profile)获取深度传感器(depth_sensor)超蛋疼的一幕 dir()
  4. linux中php配置
  5. POJ 3370 Halloween treats——鸽巢原理+思维
  6. 一行代码添加P值的可视化技巧分享~~
  7. 解决xx is not in the sudoers file. This incident will be reported.问题
  8. Window下完全卸载MySQL教程
  9. windows server 2012 安装 VC2015 安装失败0x80240017解决方法
  10. ASDM的网管的环境搭建
  11. 热敏电阻制作温度传感器的c语言,课题一NTC热敏电阻温度测量和控制系统.doc
  12. python使用有道智云翻译API
  13. C++基于libxls库读取xls文件
  14. VSCode中安装Live Server插件实现Html网页代码的实时预览
  15. python 抓取网页数据
  16. 使用Python预测黄金AU9999收盘价
  17. 中国石油大学《政治学原理》第二次在线作业
  18. Ansys Zemax / SPEOS | 3片式LCD投影仪的设计与仿真
  19. 虚拟机VMware Workstation 不支持的硬件版本
  20. matlab直流调速系统设计,直流调速系统的matlab设计与仿真系统设计

热门文章

  1. 第十一届蓝桥杯JavaB组省赛(题目及AC题解)
  2. [Java]深度剖析面向对象编程
  3. Java实现简易客房管理系统
  4. 解决使用360安装windows更新后启动慢的方法
  5. python:小乌龟turtle
  6. C3P0连接池使用时报错java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
  7. Ansys Zemax | 如何模拟部分反射和散射的表面
  8. linux配置jdk环境_linux配置jdk环境变量显示不识别的标志符
  9. YOLOv5/v7/v8首发原创改进《新颖轻量化非对称多级压缩LADH检测头》即插即用|原创改进轻量新颖ADH非对称多级压缩检测头,检测头新颖改进,YOLO检测器性能高效涨点
  10. Java侵权案落槌 谷歌胜诉甲骨文