From c532f35dff316106802df5c6f67cfb8626d86aca Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 24 Dec 2024 16:52:39 +0800
Subject: [PATCH] 临川相关调整

---
 src/pages/map/components/scomponents/layersControl.vue |  275 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 186 insertions(+), 89 deletions(-)

diff --git a/src/pages/map/components/scomponents/layersControl.vue b/src/pages/map/components/scomponents/layersControl.vue
index 56e6d9b..5e7ac88 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-03 13:44:43
+ * @LastEditTime: 2024-12-24 16:31:17
  * @FilePath: \bigScreen\src\pages\map\components\scomponents\layersControl.vue
  * @Description:
  *
@@ -55,6 +55,9 @@
 let tileLayers = new DC.TilesetLayer('tileLayers')
 window.$viewer.addLayer(tileLayers)
 
+let planToBuild = new DC.HtmlLayer('planToBuild')
+window.$viewer.addLayer(planToBuild)
+
 const {
   show: showLayerControl
 } = defineProps({
@@ -70,7 +73,7 @@
 import { getList, getGouQu } from "@/api/space/space"
 import { getList as getRiskList } from "@/api/riskSource/riskSource"
 import { getPanoramaList } from "@/api/panorama/"
-import yqfw from "@/assets/json/yqfw"
+import yqfw_01 from "@/assets/json/yqfw_01"
 // import gsgw from "@/assets/json/gsgw"
 // import rqgw from "@/assets/json/rqgw"
 import wsgw from "@/assets/json/wsgw"
@@ -116,18 +119,6 @@
         url: VITE_APP_BASE + 'mx/tile_02/tileset.json',
         label: 'tile_02'
       },
-      {
-        url: VITE_APP_BASE + 'mx/tile_03/tileset.json',
-        label: 'tile_03'
-      },
-      {
-        url: VITE_APP_BASE + 'mx/tile_04/tileset.json',
-        label: 'tile_04'
-      },
-      {
-        url: VITE_APP_BASE + 'mx/tile_05/tileset.json',
-        label: 'tile_05'
-      },
     ],
     layerName: 'hgyq'
   },
@@ -152,6 +143,7 @@
     label: '应急空间',
     children: [
       {
+        parentId: '3',
         id: '3-1',
         label: '应急池',
         type: 'layer',
@@ -159,12 +151,12 @@
         method: getList,
         params: {
           type: 1,
-          size: 1000
+          size: 1000,
         },
         backgroundIcon: VITE_APP_BASE + 'img/mapicon/yjc.png',
         className: 'yjc-box',
         showPanel: false,
-        layerName: 'yjc',
+        layerName: 'yjc-yq',
         incident: (e) => {
           const { attrParams } = e.overlay
           // 删除
@@ -175,48 +167,8 @@
           addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
           window.$viewer.addLayer(addPopLayers[attrParams.id])
           let iconEl = `<div class="marsBlueGradientPnl">
-            <div>${attrParams.firmName}</div>
-            <div>${attrParams.mainFuncName}</div>
-                </div>`
-          let divIcon = new DC.DivIcon(
-            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
-            `<div class="public-map-popup-two">
-                    ${iconEl}
-                  </div>`
-          )
-          let incident = () => {
-            destroyPop()
-          }
-          divIcon.on(DC.MouseEventType.CLICK, incident)
-          addPopLayers[attrParams.id].addOverlay(divIcon)
-        }
-      },
-      {
-        id: '3-2',
-        label: '阀门',
-        type: 'layer',
-        subType: 'labelPoint',
-        method: getList,
-        params: {
-          type: 2,
-          size: 1000
-        },
-        backgroundIcon: VITE_APP_BASE + 'img/mapicon/ysf.png',
-        className: 'ysf-box',
-        showPanel: false,
-        layerName: 'fm',
-        incident: (e) => {
-          const { attrParams } = e.overlay
-          // 删除
-          destroyPop()
-          if (!attrParams.firmName) {
-            return
-          }
-          addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
-          window.$viewer.addLayer(addPopLayers[attrParams.id])
-          let iconEl = `<div class="marsBlueGradientPnl">
-            <div>${attrParams.firmName}</div>
-            <div>${attrParams.mainFuncName}</div>
+            <div>企业名称:${attrParams.firmName}</div>
+            <div>作用:${attrParams.mainFuncName}</div>
                 </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -233,11 +185,105 @@
       },
 
       {
+        parentId: '3',
+        id: '3-2',
+        label: '阀门',
+        children: [
+          {
+            parentId: '3-2',
+            id: '3-2-1',
+            label: '园区',
+            type: 'layer',
+            subType: 'labelPoint',
+            method: getList,
+            params: {
+              type: 2,
+              size: 1000,
+              category: 1
+            },
+            backgroundIcon: VITE_APP_BASE + 'img/mapicon/ysf.png',
+            className: 'ysf-box',
+            showPanel: false,
+            layerName: 'fm-yq',
+            incident: (e) => {
+              const { attrParams } = e.overlay
+              // 删除
+              destroyPop()
+              if (!attrParams.firmName) {
+                return
+              }
+              addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
+              window.$viewer.addLayer(addPopLayers[attrParams.id])
+              let iconEl = `<div class="marsBlueGradientPnl">
+            <div>企业名称:${attrParams.firmName}</div>
+            <div>作用:${attrParams.mainFuncName}</div>
+                </div>`
+              let divIcon = new DC.DivIcon(
+                new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
+                `<div class="public-map-popup-two">
+                    ${iconEl}
+                  </div>`
+              )
+              let incident = () => {
+                destroyPop()
+              }
+              divIcon.on(DC.MouseEventType.CLICK, incident)
+              addPopLayers[attrParams.id].addOverlay(divIcon)
+            }
+          },
+          {
+            parentId: '3-2',
+            id: '3-2-2',
+            label: '企业',
+            type: 'layer',
+            subType: 'labelPoint',
+            method: getList,
+            params: {
+              type: 2,
+              size: 1000,
+              category: 2
+            },
+            backgroundIcon: VITE_APP_BASE + 'img/mapicon/ysf.png',
+            className: 'ysf-box',
+            showPanel: false,
+            layerName: 'fm-qy',
+            incident: (e) => {
+              const { attrParams } = e.overlay
+              // 删除
+              destroyPop()
+              if (!attrParams.firmName) {
+                return
+              }
+              addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
+              window.$viewer.addLayer(addPopLayers[attrParams.id])
+              let iconEl = `<div class="marsBlueGradientPnl">
+            <div>企业名称:${attrParams.firmName}</div>
+            <div>作用:${attrParams.mainFuncName}</div>
+                </div>`
+              let divIcon = new DC.DivIcon(
+                new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
+                `<div class="public-map-popup-two">
+                    ${iconEl}
+                  </div>`
+              )
+              let incident = () => {
+                destroyPop()
+              }
+              divIcon.on(DC.MouseEventType.CLICK, incident)
+              addPopLayers[attrParams.id].addOverlay(divIcon)
+            }
+          }
+        ]
+      },
+
+      {
+        parentId: '3',
         id: '3-3',
         label: '公共管网',
         children: [
           // 给水管网、污水管网、燃气管网、雨水管网
           {
+            parentId: '3-3',
             id: '3-3-2',
             label: '污水管网',
             type: 'layer',
@@ -248,6 +294,7 @@
             height: 60.2,
           },
           {
+            parentId: '3-3',
             id: '3-3-4',
             label: '雨水管网',
             type: 'layer',
@@ -281,6 +328,7 @@
       },
 
       {
+        parentId: '3',
         id: '3-4',
         label: '污水提升泵站',
         type: 'layer',
@@ -324,6 +372,7 @@
       },
 
       {
+        parentId: '3',
         id: '3-5',
         label: '水库',
         type: 'layer',
@@ -365,6 +414,7 @@
       },
 
       {
+        parentId: '3',
         id: '3-6',
         label: '应急泵',
         type: 'layer',
@@ -388,8 +438,8 @@
           addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
           window.$viewer.addLayer(addPopLayers[attrParams.name])
           let iconEl = `<div class="marsBlueGradientPnl">
-            <div>${attrParams.firmName}</div>
-            <div>${attrParams.mainFuncName}</div>
+            <div>企业名称:${attrParams.firmName}</div>
+            <div>作用:${attrParams.mainFuncName}</div>
                 </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -406,6 +456,7 @@
       },
 
       {
+        parentId: '3',
         id: '3-8',
         label: '沟渠',
         type: 'layer',
@@ -437,6 +488,7 @@
       //   layerName: 'fsclz'
       // },
       {
+        parentId: '3',
         id: '3-10',
         label: '排水口',
         type: 'layer',
@@ -460,8 +512,8 @@
           addPopLayers[attrParams.id] = new DC.HtmlLayer(attrParams.id)
           window.$viewer.addLayer(addPopLayers[attrParams.id])
           let iconEl = `<div class="marsBlueGradientPnl">
-            <div>${attrParams.firmName}</div>
-            <div>${attrParams.mainFuncName}</div>
+            <div>企业名称:${attrParams.firmName}</div>
+            <div>作用:${attrParams.mainFuncName}</div>
                 </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -499,6 +551,7 @@
     label: '风险源',
     children: [
       {
+        parentId: '4',
         id: '4-1',
         label: '一般',
         type: 'layer',
@@ -520,9 +573,9 @@
           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>
+            <li>企业名称:${attrParams.firmName || ''}</li>
+            <li>风险等级:${attrParams.riskLevelName || ''}</li>
+            <li>行业类别:${attrParams.name || ''}</li>
             </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -538,6 +591,7 @@
         }
       },
       {
+        parentId: '4',
         id: '4-2',
         label: '较大',
         type: 'layer',
@@ -559,9 +613,9 @@
           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>
+            <li>企业名称:${attrParams.firmName || ''}</li>
+            <li>风险等级:${attrParams.riskLevelName || ''}</li>
+            <li>行业类别:${attrParams.name || ''}</li>
             </div>`
           let divIcon = new DC.DivIcon(
             new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -577,6 +631,7 @@
         }
       },
       {
+        parentId: '4',
         id: '4-9',
         label: '暂定',
         type: 'layer',
@@ -624,7 +679,7 @@
     type: 'layer',
     subType: 'geojsonWall',
     layerName: 'yqfw',
-    source: yqfw
+    source: yqfw_01
   },
 
   {
@@ -736,6 +791,7 @@
 }
 
 const handleCheckChange = (data) => {
+
   let options = treeRef.value?.getCheckedNodes()
   collectedNodes.value = []
   collectNodesWithFlag(data)
@@ -847,7 +903,7 @@
 
           item.source.features.forEach(i => {
             let wall = new DC.Wall(
-              i.geometry.coordinates[0].map(d => [...d, 125].join(',')).join(';')
+              i.geometry.coordinates[0].map(d => [d[0], d[1], 125].join(',')).join(';')
             )
 
             wall.setStyle({
@@ -884,9 +940,34 @@
               computeCircle(1.6)
             )
 
-            polylineVolume.setStyle({
-              material: item.color
-            })
+            if (i.properties.RefName.indexOf('拟建') != -1) {
+              polylineVolume.setStyle({
+                material: DC.Color.fromBytes(255, 0, 0, 230)
+              })
+
+              let features = window.$turf.featureCollection(
+                i.geometry.coordinates.map(d => window.$turf.point([d[0], d[1]]))
+              )
+
+              let planCenter = window.$turf.center(features)
+
+              let planDivIcon = new DC.DivIcon(
+                new DC.Position(planCenter.geometry.coordinates[0], planCenter.geometry.coordinates[1], 60.5),
+                `<div class="public-map-popup">
+                     <div class="map-name">拟建</div>
+                  <div class="map-icon">
+                    <img src="${VITE_APP_BASE + 'img/mapicon/nj-ys.png'}">
+                  </div>
+                  </div>`
+              )
+
+              planToBuild.addOverlay(planDivIcon)
+            } else {
+              polylineVolume.setStyle({
+                material: item.color
+              })
+            }
+
             addTileLayers[item.layerName].addOverlay(polylineVolume)
           })
         } else {
@@ -932,6 +1013,10 @@
           window.$viewer && window.$viewer.removeLayer(addTileLayers[item.layerName])
           addTileLayers[item.layerName] = null
           delete addTileLayers[item.layerName]
+
+          if (item.layerName == 'ysgw' && planToBuild) {
+            planToBuild.clear()
+          }
         }
       }
     }
@@ -973,22 +1058,28 @@
 }
 
 const restHandleDelChange = (key) => {
+
   let checkIds = treeRef.value?.getCheckedKeys()
 
   if (checkIds && !checkIds.some(i => i == key)) {
     return
   }
 
-  treeRef.value?.setCheckedKeys(checkIds.filter(i => i.indexOf(key)))
-  handleCheckChange([findObjectById(data, key)])
+  let selectData = findObjectById(data, key)
+
+  let parentId = null
+  if (selectData && 'parentId' in selectData) parentId = selectData.parentId
+
+  treeRef.value?.setCheckedKeys(checkIds.filter(i => i.indexOf(key) && i != parentId))
+  handleCheckChange([selectData])
 }
 
 // 飞到园区范围
 const flyToyqfw = () => {
   window.$viewer.zoomToPosition(new DC.Position(
-    115.1021,
-    27.2360,
-    5000,
+    116.2819,
+    27.9400,
+    8000,
     0,
     -45,
     0
@@ -1012,10 +1103,8 @@
 // 关闭所有选中的,除了倾斜,园区分布,空中全景
 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`)
@@ -1026,7 +1115,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', `4-9`)
@@ -1049,14 +1137,16 @@
 
 // 销毁
 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]
-    })
-    addPopLayers = {}
+  if (addPopLayers && addPopLayers != null) {
+    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]
+      })
+      addPopLayers = {}
+    }
   }
 }
 
@@ -1081,6 +1171,13 @@
     window.$viewer && window.$viewer.removeLayer(tileLayers)
     tileLayers = null
   }
+
+  if (planToBuild) {
+    planToBuild.remove()
+    window.$viewer && window.$viewer.removeLayer(planToBuild)
+    planToBuild = null
+  }
+
   // 弹窗销毁
   destroyPop()
   addPopLayers = null

--
Gitblit v1.9.3