From e575d42358521a55549e869ab4baf4902e339481 Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Sat, 14 Jun 2025 21:42:02 +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=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E9=A3=9E=E8=A1=8C=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=9C=B0=E5=9B=BE=E7=BB=84=E4=BB=B6=20?= =?UTF-8?q?=E8=A7=84=E5=88=92=E8=B7=AF=E5=BE=84=20=20=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E5=BE=85=E7=BB=AD=E5=90=83=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B?= =?UTF-8?q?=E3=80=91=EF=BC=9A=20=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91?= =?UTF-8?q?=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MapBox.vue | 43 ++++++++++++++ .../components/main/register/flyData.vue | 58 ++++++++++++++++--- src/views/layout/index.vue | 1 - 3 files changed, 92 insertions(+), 10 deletions(-) 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 @@ + -
-
-
暂无数据
+
+
+
+
暂无数据