【类 型】:feat
【原 因】:飞行数据统计 添加地图组件 规划路径 未完待续吃 【过 程】: 【影 响】:
This commit is contained in:
parent
607ab15cf9
commit
e575d42358
@ -625,6 +625,49 @@ export default {
|
|||||||
this.guidedMarker = null // 清除当前标记
|
this.guidedMarker = null // 清除当前标记
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @description 简单画线(飞机轨迹),忽略高度,仅绘制经纬度路径
|
||||||
|
* @param {Array} coordinatesArray - 坐标数组,每项为 [lng, lat, alt]
|
||||||
|
*/
|
||||||
|
drawSimplePath (coordinatesArray) {
|
||||||
|
const coords2D = coordinatesArray.map(coord => [coord[0], coord[1]])
|
||||||
|
|
||||||
|
const geojson = {
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: {
|
||||||
|
type: 'LineString',
|
||||||
|
coordinates: coords2D
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果已有旧图层,先移除(防止报错)
|
||||||
|
if (this.map.getLayer('path')) {
|
||||||
|
this.map.removeLayer('path')
|
||||||
|
}
|
||||||
|
if (this.map.getSource('path')) {
|
||||||
|
this.map.removeSource('path')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加 source 和 layer
|
||||||
|
this.map.addSource('path', {
|
||||||
|
type: 'geojson',
|
||||||
|
data: geojson
|
||||||
|
})
|
||||||
|
|
||||||
|
this.map.addLayer({
|
||||||
|
id: 'path',
|
||||||
|
type: 'line',
|
||||||
|
source: 'path',
|
||||||
|
layout: {
|
||||||
|
'line-cap': 'round',
|
||||||
|
'line-join': 'round'
|
||||||
|
},
|
||||||
|
paint: {
|
||||||
|
'line-color': 'blue',
|
||||||
|
'line-width': 3
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @description: 创建飞机轨迹 ps:原理删除之前的轨迹 重新绘制
|
* @description: 创建飞机轨迹 ps:原理删除之前的轨迹 重新绘制
|
||||||
* @param {arr} coordinatesArray 飞机经纬高度数组
|
* @param {arr} coordinatesArray 飞机经纬高度数组
|
||||||
|
@ -7,19 +7,22 @@
|
|||||||
<el-radio-button label="飞行时长"></el-radio-button>
|
<el-radio-button label="飞行时长"></el-radio-button>
|
||||||
<el-radio-button label="飞行距离"></el-radio-button>
|
<el-radio-button label="飞行距离"></el-radio-button>
|
||||||
<el-radio-button label="消耗电量"></el-radio-button>
|
<el-radio-button label="消耗电量"></el-radio-button>
|
||||||
|
<el-radio-button label="飞行轨迹"></el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chart-area">
|
<div class="chart-area" v-if="flyDataList.length">
|
||||||
<div v-if="flyDataList.length" id="main" class="chart-container"></div>
|
<div v-if="boxShow" id="main" class="chart-container"></div>
|
||||||
<div v-else class="no-data-tip">暂无数据</div>
|
<map-box v-else ref="mapbox" />
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="no-data-tip">暂无数据</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
|
import MapBox from '@/components/MapBox'
|
||||||
import { getFlyData } from '@/utils/api/table'
|
import { getFlyData } from '@/utils/api/table'
|
||||||
import DateRangePicker from '@/components/DateRangePicker'
|
import DateRangePicker from '@/components/DateRangePicker'
|
||||||
|
|
||||||
@ -36,11 +39,13 @@ export default {
|
|||||||
flyDataList: [],
|
flyDataList: [],
|
||||||
selectedPlaneIdArr: this.$store.state.app.toFlyDataIdArr,
|
selectedPlaneIdArr: this.$store.state.app.toFlyDataIdArr,
|
||||||
dateRange: [start, end],
|
dateRange: [start, end],
|
||||||
radioClass: '飞行时长'
|
radioClass: '飞行时长',
|
||||||
|
boxShow: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
DateRangePicker
|
DateRangePicker,
|
||||||
|
MapBox
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
source () {
|
source () {
|
||||||
@ -145,10 +150,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.loadFlyData()
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
flyDataList (newVal) {
|
flyDataList (newVal) {
|
||||||
|
// 图标销毁 和 初始化
|
||||||
if (!newVal.length && this.myChart) {
|
if (!newVal.length && this.myChart) {
|
||||||
this.myChart.dispose()
|
this.myChart.dispose()
|
||||||
this.myChart = null
|
this.myChart = null
|
||||||
@ -157,6 +162,19 @@ export default {
|
|||||||
this.initChart()
|
this.initChart()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 多个飞机轨迹全部绘制
|
||||||
|
if (!this.boxShow && newVal.length) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.drawAllPathsOnMap()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
boxShow (newVal) {
|
||||||
|
if (!newVal) { // boxShow 为 false,显示地图时重新绘制轨迹
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.drawAllPathsOnMap()
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
dateRange: {
|
dateRange: {
|
||||||
handler () {
|
handler () {
|
||||||
@ -169,11 +187,34 @@ export default {
|
|||||||
this.initChart()
|
this.initChart()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
radioClass () {
|
radioClass (val) {
|
||||||
|
if (val === '飞行轨迹') {
|
||||||
|
this.boxShow = false
|
||||||
|
} else {
|
||||||
|
this.boxShow = true
|
||||||
|
this.$nextTick(() => {
|
||||||
this.initChart()
|
this.initChart()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 地图轨迹绘制
|
||||||
|
drawAllPathsOnMap () {
|
||||||
|
if (!this.$refs.mapbox) return
|
||||||
|
if (!this.flyDataList.length) return
|
||||||
|
|
||||||
|
// 清理旧轨迹(如果你的mapbox组件支持)
|
||||||
|
this.$refs.mapbox.clearPaths && this.$refs.mapbox.clearPaths()
|
||||||
|
|
||||||
|
this.flyDataList.forEach(item => {
|
||||||
|
if (item.gps_path) {
|
||||||
|
const pathArray = JSON.parse(item.gps_path)
|
||||||
|
this.$refs.mapbox.createPathWithArray(pathArray)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 获取飞行数据
|
||||||
async loadFlyData () {
|
async loadFlyData () {
|
||||||
if (this.selectedPlaneIdArr.length === 0) {
|
if (this.selectedPlaneIdArr.length === 0) {
|
||||||
this.$router.push('/register/index')
|
this.$router.push('/register/index')
|
||||||
@ -191,7 +232,6 @@ export default {
|
|||||||
const res = await getFlyData(this.selectedPlaneIdArr, startTimestamp, endTimestamp)
|
const res = await getFlyData(this.selectedPlaneIdArr, startTimestamp, endTimestamp)
|
||||||
if (res.data.status === 1) {
|
if (res.data.status === 1) {
|
||||||
this.flyDataList = res.data.dataList
|
this.flyDataList = res.data.dataList
|
||||||
console.log('飞行数据列表:', this.flyDataList)
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.data.msg)
|
this.$message.error(res.data.msg)
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,6 @@ export default {
|
|||||||
// 更新mqtt信息 选择性更新状态
|
// 更新mqtt信息 选择性更新状态
|
||||||
for (const key in jsonData) {
|
for (const key in jsonData) {
|
||||||
if (key === 'heartBeat') {
|
if (key === 'heartBeat') {
|
||||||
console.log('接收到心跳信息', plane)
|
|
||||||
// 每次接收到心跳时,更新随机数以触发 watch 监听
|
// 每次接收到心跳时,更新随机数以触发 watch 监听
|
||||||
plane.planeState.heartRandom = Math.random()
|
plane.planeState.heartRandom = Math.random()
|
||||||
plane.planeState.heartBeat = jsonData.heartBeat
|
plane.planeState.heartBeat = jsonData.heartBeat
|
||||||
|
Loading…
Reference in New Issue
Block a user