From 80879c8fb4b4263a241ce6c6cbafdc2c7dd162d6 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 28 Apr 2025 11:45:13 +0800
Subject: [PATCH] 地图初始化位置调整 地图航线加载样式调整

---
 src/components/map-container/mapContainer.vue |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/components/map-container/mapContainer.vue b/src/components/map-container/mapContainer.vue
index 4f8effb..5828a87 100644
--- a/src/components/map-container/mapContainer.vue
+++ b/src/components/map-container/mapContainer.vue
@@ -2,7 +2,7 @@
  * @Author: shuishen 1109946754@qq.com
  * @Date: 2024-10-25 15:07:51
  * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2025-04-15 21:54:01
+ * @LastEditTime: 2025-04-28 11:34:40
  * @FilePath: \drone-web-manage\src\components\map-container\mapContainer.vue
  * @Description: 
  * 
@@ -19,6 +19,8 @@
 </template>
 
 <script setup>
+import * as turf from '@turf/turf'
+
 import { nextTick, onMounted, onUnmounted } from 'vue'
 import { read } from 'xlsx'
 
@@ -65,8 +67,11 @@
         credit: 'stand_tc',
     })
 
-    window.$viewer = new DC.Viewer('viewer-container')
+    window.$viewer = new DC.Viewer('viewer-container',)
+
     window.$viewer.locationBar.enable = false
+
+    window.$viewer?.zoomToPosition(new DC.Position(115.892151, 28.676493, 1000000, 0, -90, 0))
 
     window.$viewer?.imageryLayers.addImageryProvider(imageryProvider_stand)
     window.$viewer?.imageryLayers.addImageryProvider(imageryProvider_standZh)
@@ -133,15 +138,27 @@
 
     let polyline = new DC.Polyline(positionStr)
     polyline.setStyle({
-        width: 20,
-        material: new DC.PolylineLightingTrailMaterialProperty({
-            color: DC.Color.BLUE,
-            speed: 5.0
+        width: 4,
+        material: new DC.PolylineTrailMaterialProperty({
+            color: DC.Color.DEEPSKYBLUE,
+            speed: 10
         }),
         clampToGround: true
     })
     polylineLayer.addOverlay(polyline)
-    window.$viewer?.zoomTo(polylineLayer)
+
+    const line = turf.lineString(positionStr.split(';').map(i => i.split(',')))
+    const bbox = turf.bbox(line)
+    const bboxPolygon = turf.bboxPolygon(bbox)
+    const scaledPolygon = turf.transformScale(bboxPolygon, 3)
+    const newBbox = turf.bbox(scaledPolygon)
+
+    window.$viewer?.flyToBounds(
+        newBbox,
+        { heading: 0, pitch: -90, roll: 0 },
+        () => { },
+        0
+    )
 }
 
 onMounted(() => {

--
Gitblit v1.9.3