From 79c1dc297829c7b710e8bc41051d00c4acf7043d Mon Sep 17 00:00:00 2001 From: szdot Date: Thu, 25 Jul 2024 01:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afix=20=E4=B8=8D=E6=B7=B1=E5=BA=A6=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E9=A3=9E=E6=9C=BA=E5=B1=9E=E6=80=A7=20=E3=80=90=E5=8E=9F=20=20?= =?UTF-8?q?=E5=9B=A0=E3=80=91=EF=BC=9A=E6=B7=B1=E5=BA=A6=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=20=E5=AF=BC=E8=87=B4=E5=9C=B0=E5=9B=BE=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E9=87=8D=E7=94=BB=E9=A3=9E=E6=9C=BA=20=E3=80=90=E8=BF=87=20=20?= =?UTF-8?q?=E7=A8=8B=E3=80=91=EF=BC=9A=E5=8F=96=E6=B6=88watch=20plane?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84deep=20=E3=80=90=E5=BD=B1=20=20?= =?UTF-8?q?=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MapBox.vue | 1 + .../layout/components/main/planes/index.vue | 22 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/MapBox.vue b/src/components/MapBox.vue index fc1dbdf..a4c6016 100644 --- a/src/components/MapBox.vue +++ b/src/components/MapBox.vue @@ -471,6 +471,7 @@ export default { } // 创建轨迹 this.createPathWithArray(pathArr)// 创建轨迹 + console.log(pathArr) // 镜头跟随飞机 if (isflow) { this.map.flyTo({ diff --git a/src/views/layout/components/main/planes/index.vue b/src/views/layout/components/main/planes/index.vue index 407dfa7..dae4f02 100644 --- a/src/views/layout/components/main/planes/index.vue +++ b/src/views/layout/components/main/planes/index.vue @@ -62,7 +62,6 @@ export default { * @description: 创建飞机图标 */ makePlane (plane) { - console.log('hi') let planeDefaultLngLat if (localStorage.getItem(plane.name)) { // 从本地缓存 拿飞机得初始位置 planeDefaultLngLat = JSON.parse(localStorage.getItem(plane.name)) @@ -74,7 +73,8 @@ export default { } this.$refs.mapbox.removePlanes()// 先清除画布上现有的飞机 this.$refs.mapbox.makePlane(plane)// 创建飞机 - // this.$refs.mapbox.goto({ lng: plane.lng, lat: plane.lat })// 跳转到飞机位置 + this.$refs.mapbox.goto({ lng: plane.lng, lat: plane.lat })// 跳转到飞机位置 + console.log('hi') }, /** * @description: 创建航线 @@ -100,17 +100,17 @@ export default { mounted () { if (this.plane) { this.makePlane(this.plane) // 创建飞机图标 + if (!this.plane.planeState.battCapacity) { + mqtt.publishFun(`cmd/${this.plane.macadd}`, '{"getBattCapacity":1}')// 发送设置飞机状态主题 请求飞控返回 电池总容量 + } } }, watch: { - plane: { - handler (val) { - this.makePlane(val)// 有飞机数据之后 在地图上创建飞机 - if (!val.planeState.battCapacity) { - mqtt.publishFun(`cmd/${this.plane.macadd}`, '{"getBattCapacity":1}')// 发送设置飞机状态主题 请求飞控返回 电池总容量 - } - }, - deep: true + plane (val) { + this.makePlane(val)// 有飞机数据之后 在地图上创建飞机 + if (!val.planeState.battCapacity) { + mqtt.publishFun(`cmd/${this.plane.macadd}`, '{"getBattCapacity":1}')// 发送设置飞机状态主题 请求飞控返回 电池总容量 + } }, /** * @description: 更新飞机位置 并画出轨迹 跟随飞机 @@ -125,7 +125,7 @@ export default { if (this.localCount % 100 === 1) { localStorage.setItem(this.plane.name, `{ "lng": ${lng}, "lat": ${lat} }`) } - this.$refs.mapbox.setPlaneLngLat({ lng: lng, lat: lat }, 0, val, false)// 更新飞机位置 并画出轨迹 跟随飞机 + this.$refs.mapbox.setPlaneLngLat({ lng: lng, lat: lat }, 0, val, true)// 更新飞机位置 并画出轨迹 跟随飞机 } }, deep: true