From f373e0c0797e1800bf066fdfbb748bb9242230f6 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期二, 08 七月 2025 17:46:02 +0800
Subject: [PATCH] 泥位计

---
 src/components/tools/LayerTree.vue |   54 ++++++++++++++++++++++++++----------------------------
 1 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/src/components/tools/LayerTree.vue b/src/components/tools/LayerTree.vue
index 425de2b..cbe28aa 100644
--- a/src/components/tools/LayerTree.vue
+++ b/src/components/tools/LayerTree.vue
@@ -14,7 +14,12 @@
 
 <script setup>
 import { ref, onMounted, watch, nextTick, onUnmounted, watchEffect } from "vue";
-import { createPoint, removeEntities, addTileset } from "@/utils/map";
+import {
+  createPoint,
+  removeEntities,
+  addTileset,
+  clearAllPoints,
+} from "@/utils/map";
 import { deviceDictList, getDictName } from "@/constant/dict.js";
 import { useRoute } from "vue-router";
 import {
@@ -76,7 +81,7 @@
   try {
     TerrainLayer = await earthCtrl.factory.createTerrainLayer({
       sourceType: "ctb",
-      url: "http://106.120.22.26:9103/gisserver/ctsserver/sunhugoudem84",
+      url: "http://106.120.22.26:9103/gisserver/ctsserver/sunhugoudem",
       requestVertexNormals: true,
     });
     treeMap.set("鍦板舰鏁版嵁", TerrainLayer);
@@ -238,9 +243,7 @@
   const list = treeMap.get(layerName);
   if (list && Array.isArray(list)) {
     list.forEach((entity) => {
-      if (viewer.entities.contains(entity)) {
-        viewer.entities.remove(entity);
-      }
+      clearAllPoints();
     });
   }
   treeMap.delete(layerName);
@@ -253,17 +256,14 @@
   if (simStore.DeviceShowSwitch) {
     const deviceList = simStore.devices
       .filter((item) => item.deviceName?.includes("瀛欒儭娌�"))
-      .map((item) => {
-        const entity = createPoint({
-          ...item,
-          type: getDictName(deviceDictList, item.dictDeviceType),
-          name: item.deviceName.split("瀛欒儭娌�")[1],
-          id: item.deviceId,
-          className: "device",
-          showLabel: true,
-        });
-        entity.show = true;
-        return entity;
+      .map(async (item) => {
+        const entity = viewer.entities.getById(item.deviceId);
+        item.type = getDictName(deviceDictList, item.dictDeviceType);
+        item.name = item.deviceName.split("瀛欒儭娌�")[1];
+        item.id = item.deviceId;
+        item.className = "device";
+        item.showLabel = true;
+        await createPoint(item);
       });
 
     if (deviceList.length) {
@@ -279,18 +279,16 @@
   if (simStore.DangerShowSwitch) {
     const dangerPoints = simStore.DangerPoint.filter((item) =>
       item.position?.includes("瀛欒儭娌�")
-    ).map((item) => {
-      const entity = createPoint({
-        id: item.hdId,
-        name: item.hdName,
-        latitude: item.lat,
-        longitude: item.lon,
-        showBillboard: true,
-        type: item.disasterType,
-        className: "district",
-      });
-      entity.show = true;
-      return entity;
+    ).map(async (item) => {
+      const entity = viewer.entities.getById(item.hdId);
+      item.id = item.hdId;
+      item.name = item.hdName;
+      item.latitude = item.lat;
+      item.longitude = item.lon;
+      item.showBillboard = true;
+      item.type = item.disasterType;
+      item.className = "district";
+      await createPoint(item);
     });
 
     if (dangerPoints.length) {

--
Gitblit v1.9.3