智慧园区前端大屏
shuishen
2025-08-06 3b10270c0dcc71faef1a67ea74971f2f29dc202a
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: 2025-01-08 17:28:02
 * @LastEditTime: 2025-02-19 11:42:40
 * @FilePath: \bigScreen\src\pages\map\components\scomponents\layersControl.vue
 * @Description:
 *
@@ -78,6 +78,9 @@
// import rqgw from "@/assets/json/rqgw"
import wsgw from "@/assets/json/wsgw"
import ysgw from "@/assets/json/ysgw"
import qyjgx from "@/assets/json/qyjgx"
import lx from "@/assets/json/lx"
import gt from "@/assets/json/gt"
import track from "@/assets/json/track"
import { onUnmounted } from 'vue'
import EventBus from 'utils/bus'
@@ -93,7 +96,7 @@
const { VITE_APP_BASE } = import.meta.env
// , '7', 
let indexPoint = ref(['1', '5', '7'])
let indexPoint = ref(['1', '5', '7', '8'])
const treeRef = ref(null)
@@ -110,6 +113,16 @@
  panoramaShow.value = false
}
const baseRcImages = new window.$Cesium.WebMapTileServiceImageryProvider({
  url: '/arcgis117/rest/services/DTFW/rcgyyyx/MapServer/WMTS',
  layer: 'DTFW_rcgyyyx',
  style: 'default',
  format: 'image/png',
  tileMatrixSetID: 'default028mm',
  tilingScheme: new window.$Cesium.GeographicTilingScheme(),
  tileMatrixLabels: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19']
})
const data = [
  {
    id: '1',
@@ -118,13 +131,14 @@
    subType: '3Dtile',
    urlData: [
      {
        url: '/3Dtile/rcmx/tile_01/tileset.json',
        label: 'tile_01'
        url: '/3Dtile/rcmx_t/part1/tileset.json',
        label: 'part1'
      },
      {
        url: '/3Dtile/rcmx/tile_02/tileset.json',
        label: 'tile_02'
        url: '/3Dtile/rcmx_t/part2/tileset.json',
        label: 'part2'
      },
    ],
    layerName: 'hgyq'
  },
@@ -175,6 +189,7 @@
          let iconEl = `<div class="marsBlueGradientPnl">
            <div>企业名称:${attrParams.firmName}</div>
            <div>作用:${attrParams.mainFuncName}</div>
            <div>容量:${attrParams.capacity}(m³)</div>
                </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -217,6 +232,7 @@
          let iconEl = `<div class="marsBlueGradientPnl">
            <div>企业名称:${attrParams.firmName}</div>
            <div>作用:${attrParams.mainFuncName}</div>
            <div>容量:${attrParams.capacity}(m³)</div>
                </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -259,6 +275,7 @@
          let iconEl = `<div class="marsBlueGradientPnl">
            <div>企业名称:${attrParams.firmName}</div>
            <div>作用:${attrParams.mainFuncName}</div>
            <div>容量:${attrParams.capacity}(m³)</div>
                </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -317,6 +334,7 @@
          let iconEl = `<div class="marsBlueGradientPnl">
      <div>企业名称:${attrParams.firmName}</div>
      <div>作用:${attrParams.mainFuncName}</div>
      <div>容量:${attrParams.capacity}(m³)</div>
          </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -359,6 +377,7 @@
          let iconEl = `<div class="marsBlueGradientPnl">
            <div>企业名称:${attrParams.firmName}</div>
            <div>作用:${attrParams.mainFuncName}</div>
            <div>容量:${attrParams.capacity}(m³)</div>
                </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -391,18 +410,17 @@
        layerName: 'ql'
      },
      // {
      //   parentId: '3',
      //   id: '3-9',
      //   label: '雨水管网',
      //   type: 'layer',
      //   subType: 'geojsonPipe',
      //   layerName: 'ysgw',
      //   source: ysgw,
      //   color: DC.Color.CYAN.withAlpha(0.9),
      //   height: 48,
      // },
      {
        parentId: '3',
        id: '3-9',
        label: '雨水管网',
        type: 'layer',
        subType: 'geojsonPipe',
        layerName: 'ysgw',
        source: ysgw,
        color: DC.Color.CYAN.withAlpha(0.9),
        height: 30,
      },
      {
        parentId: '3',
        id: '3-10',
@@ -412,6 +430,17 @@
        layerName: 'track',
        source: track,
        color: DC.Color.BLUE.withAlpha(0.9),
        height: 30,
      },
      {
        parentId: '3',
        id: '3-11',
        label: '企业级连接管网',
        type: 'layer',
        subType: 'geojsonPipe',
        layerName: 'qyjgx',
        source: qyjgx,
        color: DC.Color.CYAN.withAlpha(0.9),
        height: 30,
      },
    ]
@@ -432,11 +461,12 @@
          riskLevel: 1,
          size: 1000
        },
        showParams: 'category',
        showParams: 'firmName',
        className: 'fxy-ordinary',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-yb.png',
        showPanel: false,
        layerName: 'fxyOrdinary',
        customWx: true,
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
@@ -445,8 +475,9 @@
          window.$viewer.addLayer(addPopLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl">
            <li>企业名称:${attrParams.firmName || ''}</li>
            <li>行业类别:${attrParams.category || ''}</li>
            <li>风险等级:${attrParams.riskLevelName || ''}</li>
            <li>行业类别:${attrParams.name || ''}</li>
            <li>风险物资:${attrParams.name || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -472,11 +503,12 @@
          riskLevel: 2,
          size: 1000
        },
        showParams: 'category',
        className: 'fxy-larger',
        showParams: 'firmName',
        className: 'fxy-larger-b',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-zd-b.png',
        showPanel: false,
        layerName: 'fxyLarger',
        customWx: true,
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
@@ -485,8 +517,9 @@
          window.$viewer.addLayer(addPopLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl"> 
            <li>企业名称:${attrParams.firmName || ''}</li>
            <li>行业类别:${attrParams.category || ''}</li>
            <li>风险等级:${attrParams.riskLevelName || ''}</li>
            <li>行业类别:${attrParams.name || ''}</li>
            <li>风险物资:${attrParams.name || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -512,11 +545,12 @@
          riskLevel: 3,
          size: 1000
        },
        showParams: 'category',
        className: 'fxy-larger-b',
        showParams: 'firmName',
        className: 'fxy-larger',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-jd.png',
        showPanel: false,
        layerName: 'fxyLargerB',
        customWx: true,
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
@@ -525,8 +559,9 @@
          window.$viewer.addLayer(addPopLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl"> 
            <li>企业名称:${attrParams.firmName || ''}</li>
            <li>行业类别:${attrParams.category || ''}</li>
            <li>风险等级:${attrParams.riskLevelName || ''}</li>
            <li>行业类别:${attrParams.name || ''}</li>
            <li>风险物资:${attrParams.name || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
@@ -552,11 +587,12 @@
          riskLevel: 9,
          size: 1000
        },
        showParams: 'category',
        showParams: 'firmName',
        className: 'fxy-zd',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-zd.png',
        showPanel: false,
        layerName: 'fxyZdLarger',
        customWx: true,
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
@@ -580,7 +616,32 @@
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      }
      },
      {
        parentId: '4',
        id: '4-5',
        label: '路线',
        type: 'layer',
        subType: 'geojsonLx',
        layerName: 'lx',
        source: lx,
        color: DC.Color.CYAN.withAlpha(0.9),
        height: 30,
      },
      {
        parentId: '4',
        id: '4-6',
        label: '岗亭',
        type: 'layer',
        subType: 'geojsonGt',
        layerName: 'gt',
        showPanel: false,
        className: 'gt-zd',
        source: gt,
        color: DC.Color.CYAN.withAlpha(0.9),
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/gt.png',
        height: 30,
      },
    ]
  },
@@ -620,6 +681,15 @@
      panoramaUrl.value = attrParams.url
      panoramaShow.value = true
    }
  },
  {
    id: '8',
    label: '瑞昌影像',
    type: 'layer',
    subType: 'baseMap',
    layerName: 'baseMap',
    source: baseRcImages,
  },
  /* {
@@ -711,6 +781,7 @@
  collectNodesWithFlag(data)
  collectedNodes.value.forEach(item => {
    // console.log(item, 1111111111111111112)
    if (options?.some(i => i.id == item.id)) {
      //  const window.$Cesium  = DC
@@ -737,10 +808,9 @@
              // progressiveResolutionHeightFraction: 0.5,
              // baseScreenSpaceError: 1024
              skipLevelOfDetail: true,
              baseScreenSpaceError: 1024,
              maximumScreenSpaceError: 32, // 数值加大,能让最终成像变模糊
              maximumScreenSpaceError: 16, // 数值加大,能让最终成像变模糊
              skipScreenSpaceErrorFactor: 128,
              skipLevels: 5,
              immediatelyLoadDesiredLevelOfDetail: false,
@@ -808,6 +878,11 @@
                  return
                }
                if (mapStore.startCustomWx && item.customWx) {
                  EventBus.emit('wxEntityClick', e)
                  return
                }
                incident(e)
              })
@@ -854,13 +929,13 @@
            }
            return positions
          }
          item.source.geometries.forEach(i => {
          item.source.features.forEach(i => {
            let polylineVolume = new DC.PolylineVolume(
              i.coordinates.map(d => [d[0], d[1], item.height].join(',')).join(';'),
              i.geometry.coordinates.map(d => [d[0], d[1], item.height].join(',')).join(';'),
              computeCircle(1.6)
            )
            if ('properties' in i && i.properties?.RefName.indexOf('拟建') != -1) {
            if ('RefName' in i.properties && i.properties.RefName.indexOf('拟建') != -1) {
              polylineVolume.setStyle({
                material: DC.Color.fromBytes(255, 0, 0, 230)
              })
@@ -887,7 +962,23 @@
                material: item.color
              })
            }
            // 雨水管网流向
            if (item.layerName === 'ysgw') {
              let ss = i.properties.qd + ',' + item.height + ';' + i.properties.zd + ',' + item.height
              let polyline1 = new DC.Polyline(ss)
              polyline1.setStyle({
                width: 10,
                arcType: 1,
                material: new DC.PolylineImageTrailMaterialProperty({
                  color: DC.Color.GREEN,
                  speed: 20,
                  image: VITE_APP_BASE + 'img/mapicon/right.png',
                  repeat: { x: 30, y: 1 }
                }),
                clampToGround: false
              })
              addTileLayers[item.layerName].addOverlay(polyline1)
            }
            addTileLayers[item.layerName].addOverlay(polylineVolume)
          })
        } else {
@@ -911,11 +1002,141 @@
        } else {
          addTileLayers[item.layerName].show = true
        }
        // 路线
      } else if (item.subType == 'geojsonLx') {
        if (!addTileLayers[item.layerName]) {
          addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(addTileLayers[item.layerName])
          item.source.features.forEach(i => {
            let ss = i.geometry.coordinates.map(d => [...d, item.height].join(',')).join(';')
            let Polyline = new DC.Polyline(i.geometry.coordinates.map(d => [...d, item.height].join(',')).join(';'))
            Polyline.setStyle({
              width: 3,
              // material: DC.Color.BLUE,
              material: new DC.PolylineTrailMaterialProperty({
                color: DC.Color.RED,
                speed: 10
              }),
              clampToGround: true
            })
            addTileLayers[item.layerName].addOverlay(Polyline)
          })
        } else {
          addTileLayers[item.layerName].show = true
        }
        // 岗亭
      } else if (item.subType == 'geojsonGt') {
        // if (!addTileLayers[item.layerName]) {
        //   addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
        //   window.$viewer.addLayer(addTileLayers[item.layerName])
        //   item.source.features.forEach(i => {
        //     let iconEl = ''
        //     if ('showPanel' in item && item.showPanel == false) {
        //       if (item.backgroundIcon) {
        //         iconEl = `
        //           <div class="map-name">${i.properties.O_Name}</div>
        //           <div class="map-icon">
        //             <img src="${item.backgroundIcon}">
        //           </div>
        //           `
        //       }
        //     } else {
        //       iconEl = `<div class="marsBlueGradientPnl">
        //           <div>${i.properties.O_Name}</div>
        //         </div>`
        //     }
        //     console.log(i.geometry.coordinates[0], "2222222222222222222")
        //     console.log(i.properties.O_Name, "3333333333333333")
        //     let divIcon = new DC.DivIcon(
        //       new DC.Position('115.60241996718104', '29.818985725785911'),
        //       `<div class="public-map-popup ${item.className || ''}">
        //             ${iconEl}
        //           </div>`
        //     )
        //     addTileLayers[item.layerName].addOverlay(divIcon)
        //   })
        // } else {
        //   addTileLayers[item.layerName].show = true
        // }
        if (!addTileLayers[item.layerName]) {
          addTileLayers[item.layerName] = new DC.HtmlLayer(item.layerName)
          window.$viewer.addLayer(addTileLayers[item.layerName])
          // item.method(item.params).then(res => {
          // let data = res.data.data.records
          item.source.features.forEach(i => {
            let iconEl = ''
            if ('showPanel' in item && item.showPanel == false) {
              if (item.backgroundIcon) {
                iconEl = `
                  <div class="map-name">${i.properties.O_Name}</div>
                  <div class="map-icon">
                    <img src="${item.backgroundIcon}">
                  </div>
                  `
              }
            } else {
              iconEl = `<div class="marsBlueGradientPnl">
                  <div>${i.properties.O_Name}</div>
                </div>`
            }
            let divIcon = new DC.DivIcon(
              new DC.Position(i.geometry.coordinates[0], i.geometry.coordinates[1], i.ele || 64),
              `<div class="public-map-popup ${item.className || ''}">
                    ${iconEl}
                  </div>`
            )
            divIcon.attrParams = i
            // let incident = () => {
            // }
            // if (item.incident) incident = item.incident
            // divIcon.on(DC.MouseEventType.CLICK, (e) => {
            //   if (mapStore.editPoint) {
            //     moveEntity = e
            //     return
            //   }
            //   if (mapStore.startCustomWx && item.customWx) {
            //     EventBus.emit('wxEntityClick', e)
            //     return
            //   }
            //   incident(e)
            // })
            addTileLayers[item.layerName].addOverlay(divIcon)
            // })
          })
        } else {
          addTileLayers[item.layerName].show = true
        }
      } else if (item.subType == 'baseMap') {
        if (addTileLayers[item.layerName]) {
          addTileLayers[item.layerName].show = true
          return
        }
        addTileLayers[item.layerName] = window.$viewer?.imageryLayers.addImageryProvider(item.source)
      }
    } else {
      if (addTileLayers[item.layerName]) {
        if (item.subType == '3Dtile') {
          addTileLayers[item.layerName].forEach(m => m.show = false)
        } else if (item.subType == 'baseMap') {
          addTileLayers[item.layerName].show = false
        } else {
          addTileLayers[item.layerName].clear()
          window.$viewer && window.$viewer.removeLayer(addTileLayers[item.layerName])
@@ -923,6 +1144,9 @@
          delete addTileLayers[item.layerName]
          if (item.layerName == 'ysgw' && planToBuild) {
            planToBuild.clear()
          }
          if (item.layerName == 'qyjgx' && planToBuild) {
            planToBuild.clear()
          }
        }
@@ -985,9 +1209,9 @@
// 飞到园区范围
const flyToyqfw = () => {
  window.$viewer.zoomToPosition(new DC.Position(
    115.6050,
    29.7420,
    6000,
    115.6080,
    29.7880,
    3000,
    0,
    -45,
    0
@@ -1078,12 +1302,15 @@
  EventBus.emit('restHandleDelChange', `3-7`)
  EventBus.emit('restHandleDelChange', `3-8`)
  EventBus.emit('restHandleDelChange', `3-9`)
  EventBus.emit('restHandleDelChange', `3-11`)
  EventBus.emit('restHandleDelChange', `4-1`)
  EventBus.emit('restHandleDelChange', `4-2`)
  EventBus.emit('restHandleDelChange', `4-3`)
  EventBus.emit('restHandleDelChange', `4-9`)
  EventBus.emit('restHandleDelChange', `4-5`)
  EventBus.emit('restHandleDelChange', `4-6`)
  EventBus.emit('restHandleDelChange', `8`)
  destroyPop()
}
@@ -1117,11 +1344,13 @@
onUnmounted(() => {
  let arr = Object.keys(addTileLayers)
  arr.forEach(i => {
    if (i == 'hgyq') {
    if (i == 'hgyq' || i == 'hgyqT') {
      addTileLayers[i].forEach(t => {
        tileLayers.removeOverlay(t)
        t = null
      })
    } else if (i == 'baseMap') {
      window.$viewer?.imageryLayers.remove(addTileLayers[i])
    } else {
      addTileLayers[i] && window.$viewer && window.$viewer.removeLayer(addTileLayers[i])
    }