diff --git a/src/components/MapBox.vue b/src/components/MapBox.vue index 9ce0d83..e3ea6b4 100644 --- a/src/components/MapBox.vue +++ b/src/components/MapBox.vue @@ -625,6 +625,49 @@ export default { 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:原理删除之前的轨迹 重新绘制 * @param {arr} coordinatesArray 飞机经纬高度数组 diff --git a/src/views/layout/components/main/register/flyData.vue b/src/views/layout/components/main/register/flyData.vue index 258da0e..756c6be 100644 --- a/src/views/layout/components/main/register/flyData.vue +++ b/src/views/layout/components/main/register/flyData.vue @@ -7,19 +7,22 @@ + -
-
-
暂无数据
+
+
+
+
暂无数据