From 769f362f3d91ca4336c6cd74a78aa02e2c9ceb33 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 03 Dec 2024 13:08:59 +0800
Subject: [PATCH] 应急空间调整

---
 src/pages/map/components/scomponents/layersControl.vue |  302 ++++++++++++++++++++++++++++---------------------
 1 files changed, 173 insertions(+), 129 deletions(-)

diff --git a/src/pages/map/components/scomponents/layersControl.vue b/src/pages/map/components/scomponents/layersControl.vue
index e455183..ab32dbb 100644
--- a/src/pages/map/components/scomponents/layersControl.vue
+++ b/src/pages/map/components/scomponents/layersControl.vue
@@ -2,7 +2,7 @@
  * @Author: shuishen 1109946754@qq.com
  * @Date: 2024-10-31 10:47:29
  * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2024-12-02 19:46:13
+ * @LastEditTime: 2024-12-02 22:20:32
  * @FilePath: \bigScreen\src\pages\map\components\scomponents\layersControl.vue
  * @Description:
  *
@@ -50,7 +50,7 @@
 </template>
 
 <script setup>
-let addPupoLayers = {}
+let addPopLayers = {}
 let addTileLayers = {}
 let tileLayers = new DC.TilesetLayer('tileLayers')
 window.$viewer.addLayer(tileLayers)
@@ -79,10 +79,12 @@
 import EventBus from 'utils/bus'
 import { usePointStore } from 'store/usepoint'
 const pointStore = usePointStore()
+import { useRouter } from 'vue-router'
+const router = useRouter()
 
 const { VITE_APP_BASE } = import.meta.env
 // , '7', 
-let indexPoint = ref(['1', '5'])
+let indexPoint = ref(['1', '5', '7'])
 
 const treeRef = ref(null)
 
@@ -166,15 +168,15 @@
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
-          if (!attrParams.imageUrl) {
+          destroyPop()
+          if (!attrParams.firmName) {
             return
           }
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
+          window.$viewer.addLayer(addPopLayers[attrParams.id])
           let iconEl = `<div class="marsBlueGradientPnl">
-            <div>${attrParams.fullName}</div>
-            <img src="${attrParams.imageUrl}" />
+            <div>${attrParams.firmName}</div>
+            <div>${attrParams.mainFuncName}</div>
                 </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -183,10 +185,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.id].addOverlay(divIcon)
         }
       },
       {
@@ -206,15 +208,15 @@
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
-          if (!attrParams.imageUrl) {
+          destroyPop()
+          if (!attrParams.firmName) {
             return
           }
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
+          window.$viewer.addLayer(addPopLayers[attrParams.id])
           let iconEl = `<div class="marsBlueGradientPnl">
-                  <div>${attrParams.fullName}</div>
-                  <img src="${attrParams.imageUrl}" width="160" height="160" />
+            <div>${attrParams.firmName}</div>
+            <div>${attrParams.mainFuncName}</div>
                 </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -223,10 +225,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.id].addOverlay(divIcon)
         }
       },
 
@@ -236,16 +238,6 @@
         children: [
           // 给水管网、污水管网、燃气管网、雨水管网
           {
-            id: '3-3-1',
-            label: '给水管网',
-            type: 'layer',
-            subType: 'geojsonPipe',
-            layerName: 'gsgw',
-            source: gsgw,
-            color: DC.Color.BLUE.withAlpha(0.9),
-            height: 65,
-          },
-          {
             id: '3-3-2',
             label: '污水管网',
             type: 'layer',
@@ -253,17 +245,7 @@
             layerName: 'wsgw',
             source: wsgw,
             color: DC.Color.DARKBLUE.withAlpha(0.9),
-            height: 68,
-          },
-          {
-            id: '3-3-3',
-            label: '燃气管网',
-            type: 'layer',
-            subType: 'geojsonPipe',
-            layerName: 'rqgw',
-            source: rqgw,
-            color: DC.Color.RED.withAlpha(0.9),
-            height: 71,
+            height: 60.2,
           },
           {
             id: '3-3-4',
@@ -273,7 +255,27 @@
             layerName: 'ysgw',
             source: ysgw,
             color: DC.Color.CYAN.withAlpha(0.9),
-            height: 75,
+            height: 60,
+          },
+          {
+            id: '3-3-1',
+            label: '给水管网',
+            type: 'layer',
+            subType: 'geojsonPipe',
+            layerName: 'gsgw',
+            source: gsgw,
+            color: DC.Color.BLUE.withAlpha(0.9),
+            height: 60.4,
+          },
+          {
+            id: '3-3-3',
+            label: '燃气管网',
+            type: 'layer',
+            subType: 'geojsonPipe',
+            layerName: 'rqgw',
+            source: rqgw,
+            color: DC.Color.RED.withAlpha(0.9),
+            height: 60.6,
           },
         ]
       },
@@ -284,20 +286,25 @@
         type: 'layer',
         subType: 'labelPoint',
         method: getList,
+        // className: 'sk-box',
+        // showPanel: false,
         params: {
           type: 4,
           size: 1000
         },
+        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wstsb.png',
+        className: 'yjc-box',
+        showPanel: false,
         layerName: 'wstsbz',
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
+          destroyPop()
           if (!attrParams.imageUrl) {
             return
           }
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
+          window.$viewer.addLayer(addPopLayers[attrParams.name])
           let iconEl = `<div class="marsBlueGradientPnl">
                   <div>${attrParams.fullName}</div>
                   <img src="${attrParams.imageUrl}" width="160" height="160" />
@@ -309,10 +316,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.name].addOverlay(divIcon)
         }
       },
 
@@ -333,14 +340,14 @@
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
+          destroyPop()
           if (!attrParams.imageUrl) {
             return
           }
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
+          window.$viewer.addLayer(addPopLayers[attrParams.name])
           let iconEl = `<div class="marsBlueGradientPnl">
-                   <div>${attrParams.fullName}</div>
+                   <div>${attrParams.firmName}</div>
                   <img src="${attrParams.imageUrl}" width="160" height="160" />
                 </div>`
           let divIcon = new DC.DivIcon(
@@ -350,10 +357,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.name].addOverlay(divIcon)
         }
       },
 
@@ -374,15 +381,15 @@
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
-          if (!attrParams.imageUrl) {
+          destroyPop()
+          if (!attrParams.firmName) {
             return
           }
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
+          window.$viewer.addLayer(addPopLayers[attrParams.name])
           let iconEl = `<div class="marsBlueGradientPnl">
-                  <div>${attrParams.fullName}</div>
-                  <img src="${attrParams.imageUrl}" width="160" height="160" />
+            <div>${attrParams.firmName}</div>
+            <div>${attrParams.mainFuncName}</div>
                 </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -391,10 +398,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.name].addOverlay(divIcon)
         }
       },
 
@@ -413,22 +420,22 @@
         showPanel: false,
         layerName: 'gouqu'
       },
-      {
-        id: '3-9',
-        label: '废水处理站',
-        type: 'layer',
-        subType: 'labelPoint',
-        method: getList,
-        params: {
-          type: 9,
-          size: 1000
-          // name: '吉水县绿源污水处理厂',
-        },
-        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsclc.png',
-        className: 'xfs-box',
-        showPanel: false,
-        layerName: 'fsclz'
-      },
+      // {
+      //   id: '3-9',
+      //   label: '废水处理站',
+      //   type: 'layer',
+      //   subType: 'labelPoint',
+      //   method: getList,
+      //   params: {
+      //     type: 9,
+      //     size: 1000
+      //     // name: '吉水县绿源污水处理厂',
+      //   },
+      //   backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsclc.png',
+      //   className: 'xfs-box',
+      //   showPanel: false,
+      //   layerName: 'fsclz'
+      // },
       {
         id: '3-10',
         label: '排水口',
@@ -444,21 +451,21 @@
         showPanel: false,
         layerName: 'psk'
       },
-      {
-        id: '3-11',
-        label: '污水池',
-        type: 'layer',
-        subType: 'labelPoint',
-        method: getList,
-        params: {
-          type: 11,
-          size: 1000
-        },
-        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsc.png',
-        className: 'xfs-box',
-        showPanel: false,
-        layerName: 'wsc'
-      }
+      // {
+      //   id: '3-11',
+      //   label: '污水池',
+      //   type: 'layer',
+      //   subType: 'labelPoint',
+      //   method: getList,
+      //   params: {
+      //     type: 11,
+      //     size: 1000
+      //   },
+      //   backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsc.png',
+      //   className: 'xfs-box',
+      //   showPanel: false,
+      //   layerName: 'wsc'
+      // }
     ]
   },
 
@@ -478,17 +485,19 @@
         },
         showParams: 'category',
         className: 'fxy-ordinary',
-        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy.png',
+        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-yb.png',
         showPanel: false,
         layerName: 'fxyOrdinary',
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          destroyPop()
+          addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
+          window.$viewer.addLayer(addPopLayers[attrParams.name])
           let iconEl = `<div class="marsBlueGradientPnl">
+            <li>${attrParams.firmName || ''}</li>
             <li>${attrParams.name || ''}</li>
+            <li>${attrParams.riskLevelName || ''}</li>
             </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -497,10 +506,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.name].addOverlay(divIcon)
         }
       },
       {
@@ -515,17 +524,19 @@
         },
         showParams: 'category',
         className: 'fxy-larger',
-        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy.png',
+        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-jd.png',
         showPanel: false,
         layerName: 'fxyLarger',
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
-          destroy()
-          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
-          window.$viewer.addLayer(addPupoLayers[attrParams.name])
+          destroyPop()
+          addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
+          window.$viewer.addLayer(addPopLayers[attrParams.name])
           let iconEl = `<div class="marsBlueGradientPnl"> 
+            <li>${attrParams.firmName || ''}</li>
             <li>${attrParams.name || ''}</li>
+            <li>${attrParams.riskLevelName || ''}</li>
             </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -534,10 +545,10 @@
                   </div>`
           )
           let incident = () => {
-            destroy()
+            destroyPop()
           }
           divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPupoLayers[attrParams.name].addOverlay(divIcon)
+          addPopLayers[attrParams.name].addOverlay(divIcon)
         }
       }
     ]
@@ -683,7 +694,7 @@
           // })
           addTileLayers[item.layerName] = []
           item.urlData.forEach((m, ind) => {
-            let tile = new DC.Tileset(m.url, {
+            addTileLayers[item.layerName][ind] = new DC.Tileset(m.url, {
               maximumMemoryUsage: 1024,
               maximumScreenSpaceError: 8,
               skipLevels: 5,
@@ -692,13 +703,8 @@
               progressiveResolutionHeightFraction: 0.5,
               baseScreenSpaceError: 1024
             })
-            tile.setSplitDirection(1)
             // tile.setHeight(-420)
-            // tile.setSplitDirection(-1)
-            window.$viewer.sceneSplit.addTileset(tile)
-            tileLayers.addOverlay(tile)
-            window.$viewer.sceneSplit.enable = false
-            addTileLayers[item.layerName][ind] = tile
+            tileLayers.addOverlay(addTileLayers[item.layerName][ind])
           })
         } else {
           addTileLayers[item.layerName].forEach(m => m.show = true)
@@ -792,7 +798,7 @@
           item.source.features.forEach(i => {
             let polylineVolume = new DC.PolylineVolume(
               i.geometry.coordinates.map(d => [d[0], d[1], item.height].join(',')).join(';'),
-              computeCircle(2)
+              computeCircle(1.6)
             )
 
             polylineVolume.setStyle({
@@ -910,38 +916,70 @@
 EventBus.on('restHandleCheckChange', restHandleCheckChange)
 EventBus.on('restHandleDelChange', restHandleDelChange)
 EventBus.on('flyToyqfw', flyToyqfw)
+EventBus.on('destroyPop', destroyPop)
 
 onMounted(() => {
-  setTimeout(() => {
-    // handleCheckChange(data.filter(i => indexPoint.value.includes(i.id)))
-  }, 3000)
+  handleCheckChange(data.filter(i => indexPoint.value.includes(i.id)))
 })
 
 // const sharedData = computed(() => pointStore.sharedData);
 // watch(sharedData, (newValue) => {
 // });
 
+// 关闭所有选中的,除了倾斜,园区分布,空中全景
+const closeAll = () => {
+  EventBus.emit('restHandleDelChange', `2`)
+  EventBus.emit('restHandleDelChange', `3`)
+  EventBus.emit('restHandleDelChange', `3-1`)
+  EventBus.emit('restHandleDelChange', `3-2`)
+  EventBus.emit('restHandleDelChange', `3-3`)
+  EventBus.emit('restHandleDelChange', `3-3-1`)
+  EventBus.emit('restHandleDelChange', `3-3-2`)
+  EventBus.emit('restHandleDelChange', `3-3-3`)
+  EventBus.emit('restHandleDelChange', `3-3-4`)
+  EventBus.emit('restHandleDelChange', `3-4`)
+  EventBus.emit('restHandleDelChange', `3-5`)
+  EventBus.emit('restHandleDelChange', `3-6`)
+  EventBus.emit('restHandleDelChange', `3-7`)
+  EventBus.emit('restHandleDelChange', `3-8`)
+  // EventBus.emit('restHandleDelChange', `3-9`)
+  EventBus.emit('restHandleDelChange', `4`)
+  EventBus.emit('restHandleDelChange', `4-1`)
+  EventBus.emit('restHandleDelChange', `4-2`)
+  EventBus.emit('restHandleDelChange', `8`)
+  destroyPop()
+}
+
+// const sharedData = computed(() => pointStore.sharedData);
+// watch(sharedData, (newValue) => {
+// });
+// 监听当前路由路径的变化
+watch(() => router.currentRoute.value.path,
+  (newPath, oldPath) => {
+    console.log(`Current path changed from ${oldPath} to ${newPath}`)
+    closeAll()
+  },
+  { immediate: true }
+)
+
 // 销毁
-function destroy () {
-  let arr = Object.keys(addPupoLayers)
-  arr.filter(i => i != 'hgyq').forEach(i => {
-    addPupoLayers[i] && window.$viewer && window.$viewer.removeLayer(addPupoLayers[i])
-    addPupoLayers[i] = null
-    delete addPupoLayers[i]
+function destroyPop () {
+  let arr = Object.keys(addPopLayers)
+  if(arr.length > 0){
+    arr.forEach(i => {
+    addPopLayers[i] && window.$viewer && window.$viewer.removeLayer(addPopLayers[i])
+    addPopLayers[i] = null
+    delete addPopLayers[i]
   })
-  addPupoLayers = {}
+  addPopLayers = {}
+  }
 }
 
 onUnmounted(() => {
-  if (tileLayers) {
-    tileLayers.clear()
-    window.$viewer && window.$viewer.removeLayer(tileLayers)
-    tileLayers = null
-  }
-
   let arr = Object.keys(addTileLayers)
   arr.forEach(i => {
     if (i == 'hgyq') {
+      tileLayers.removeOverlay(addTileLayers[i])
       addTileLayers[i] = null
       delete addTileLayers[i]
     } else {
@@ -951,9 +989,15 @@
     }
   })
   addTileLayers = null
+
+  if (tileLayers) {
+    tileLayers.remove()
+    window.$viewer && window.$viewer.removeLayer(tileLayers)
+    tileLayers = null
+  }
   // 弹窗销毁
-  destroy()
-  addPupoLayers = null
+  destroyPop()
+  addPopLayers = null
 
   EventBus.off('restHandleCheckChange', restHandleCheckChange)
   EventBus.off('restHandleDelChange', restHandleDelChange)

--
Gitblit v1.9.3