From 0da0753a75690626c8239ff0a03e0ad5042cf72e Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 07 May 2025 10:05:03 +0800
Subject: [PATCH] 选择航线,地图展示该航线的机巢位置及对应的航点

---
 src/components/map-container/mapContainer.vue |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/components/map-container/mapContainer.vue b/src/components/map-container/mapContainer.vue
index 73ff5fa..f1b9be9 100644
--- a/src/components/map-container/mapContainer.vue
+++ b/src/components/map-container/mapContainer.vue
@@ -24,10 +24,14 @@
 import { nextTick, onMounted, onUnmounted } from 'vue'
 import { read } from 'xlsx'
 
+import startPng from '@/assets/map_images/Startingpointicon.png'
+import endPng from '@/assets/map_images/EndPointicon.png'
+
 window.$viewer = null
 window.$Cesium = null
 let pointLayer = null
 let polylineLayer = null
+let pointHtmlLayer = null
 
 const { VITE_APP_BASE } = import.meta.env
 // import * as Cesium from 'cesium'
@@ -82,6 +86,8 @@
     window.$viewer?.addLayer(pointLayer)
     polylineLayer = new DC.VectorLayer('polylineLayer')
     window.$viewer?.addLayer(polylineLayer)
+    pointHtmlLayer = new DC.HtmlLayer('pointHtmlLayer')
+    window.$viewer?.addLayer(pointHtmlLayer)
 
     isViewerReady.value = true
 }
@@ -125,6 +131,7 @@
  */
 function addPolyline (data) {
     if (polylineLayer) polylineLayer.clear()
+    if (pointHtmlLayer) pointHtmlLayer.clear()
 
     if (data.length === 0) return
 
@@ -145,6 +152,38 @@
     })
     polylineLayer.addOverlay(polyline)
 
+
+    data.forEach((item, index) => {
+        const [lng, lat] = item
+        let position = new DC.Position(lng, lat)
+
+        console.log(lng, lat)
+        let billboard = null
+
+        if (index === 0) {
+            billboard = new DC.Billboard(position, startPng)
+        }
+
+        if (index === data.length - 1) {
+            billboard = new DC.Billboard(position, endPng)
+        }
+
+
+        billboard && (billboard.size = [20, 20])
+        billboard && (billboard.setStyle({
+            "pixelOffset": { "x": 0, "y": -8 }
+        }))
+        billboard && polylineLayer.addOverlay(billboard)
+
+        if (index !== 0 && index !== data.length - 1) {
+            let divIcon = new DC.DivIcon(
+                position,
+                `<div class="point-icon-box">${index}</div>`
+            )
+            pointHtmlLayer.addOverlay(divIcon)
+        }
+    })
+
     const line = turf.lineString(positionStr.split(';').map(i => i.split(',')))
     const bbox = turf.bbox(line)
     const bboxPolygon = turf.bboxPolygon(bbox)

--
Gitblit v1.9.3