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