智慧园区前端大屏
shuishen
2024-12-16 14230ac0316d1e403c54b5a73430bad8ebad00e7
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-10 14:45:28
 * @LastEditTime: 2024-12-16 19:15:27
 * @FilePath: \bigScreen\src\pages\map\components\scomponents\layersControl.vue
 * @Description:
 *
@@ -85,6 +85,24 @@
import { useRouter } from 'vue-router'
const router = useRouter()
// import yjkjGc from "@/assets/json/yjkj-gc"
// let newYjkj = yjkjGc.map(item => {
//   let point = DC.CoordTransform.GCJ02ToWGS84(item.lng, item.lat)
//   return {
//     ...item,
//     lng: point[0],
//     lat: point[1]
//   }
// })
// console.log(newYjkj, 4444)
// GCJ02ToWGS84
const { VITE_APP_BASE } = import.meta.env
// , '7', 
let indexPoint = ref(['1', '5', '7'])
@@ -112,24 +130,8 @@
    subType: '3Dtile',
    urlData: [
      {
        url: VITE_APP_BASE + 'newMx/mx/tile_01/tileset.json',
        url: VITE_APP_BASE + 'xinganTileset/tileset.json',
        label: 'tile_01'
      },
      {
        url: VITE_APP_BASE + 'newMx/mx/tile_02/tileset.json',
        label: 'tile_02'
      },
      {
        url: VITE_APP_BASE + 'newMx/mx/tile_03/tileset.json',
        label: 'tile_03'
      },
      {
        url: VITE_APP_BASE + 'newMx/mx/tile_04/tileset.json',
        label: 'tile_04'
      },
      {
        url: VITE_APP_BASE + 'newMx/mx/tile_05/tileset.json',
        label: 'tile_05'
      },
    ],
    layerName: 'hgyq'
@@ -158,266 +160,29 @@
        parentId: '3',
        id: '3-1',
        label: '应急池',
        children: [
          {
            parentId: '3-1',
            id: '3-1-1',
            label: '园区',
            type: 'layer',
            subType: 'labelPoint',
            method: getList,
            params: {
              type: 1,
              size: 1000,
              category: 1
            },
            backgroundIcon: VITE_APP_BASE + 'img/mapicon/yjc.png',
            className: 'yjc-box',
            showPanel: false,
            layerName: 'yjc-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-1',
            id: '3-1-2',
            label: '企业',
            type: 'layer',
            subType: 'labelPoint',
            method: getList,
            params: {
              type: 1,
              size: 1000,
              category: 2
            },
            backgroundIcon: VITE_APP_BASE + 'img/mapicon/yjc.png',
            className: 'yjc-box',
            showPanel: false,
            layerName: 'yjc-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-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',
            subType: 'geojsonPipe',
            layerName: 'wsgw',
            source: wsgw,
            color: DC.Color.DARKBLUE.withAlpha(0.9),
            height: 60.2,
          },
          {
            parentId: '3-3',
            id: '3-3-4',
            label: '雨水管网',
            type: 'layer',
            subType: 'geojsonPipe',
            layerName: 'ysgw',
            source: ysgw,
            color: DC.Color.CYAN.withAlpha(0.9),
            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,
          // },
        ]
      },
      {
        parentId: '3',
        id: '3-4',
        label: '污水提升泵站',
        type: 'layer',
        subType: 'labelPoint',
        method: getList,
        // className: 'sk-box',
        // showPanel: false,
        params: {
          type: 4,
          size: 1000
          type: 1,
          size: 1000,
        },
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wstsb.png',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/yjc.png',
        className: 'yjc-box',
        showPanel: false,
        layerName: 'wstsbz',
        layerName: 'yjc-yq',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          destroyPop()
          if (!attrParams.imageUrl) {
          if (!attrParams.firmName) {
            return
          }
          addPopLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          window.$viewer.addLayer(addPopLayers[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),
@@ -429,7 +194,49 @@
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPopLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.id].addOverlay(divIcon)
        }
      },
      {
        parentId: '3',
        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-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)
        }
      },
@@ -478,7 +285,7 @@
      {
        parentId: '3',
        id: '3-6',
        label: '应急泵',
        label: '坑塘',
        type: 'layer',
        subType: 'labelPoint',
        method: getList,
@@ -519,13 +326,13 @@
      {
        parentId: '3',
        id: '3-8',
        label: '沟渠',
        id: '3-7',
        label: '明渠',
        type: 'layer',
        subType: 'geojsonPolygon',
        method: getGouQu,
        subType: 'labelPoint',
        method: getList,
        params: {
          type: 8,
          type: 7,
          size: 1000
        },
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/gouqu.png',
@@ -533,31 +340,30 @@
        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'
      // },
      {
        parentId: '3',
        id: '3-10',
        label: '排水口',
        id: '3-8',
        label: '桥梁',
        type: 'layer',
        subType: 'labelPoint',
        method: getList,
        params: {
          type: 10,
          type: 8,
          size: 1000
        },
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsclc.png',
        className: 'xfs-box',
        showPanel: false,
        layerName: 'fsclz'
      },
      {
        parentId: '3',
        id: '3-9',
        label: '湿地',
        type: 'layer',
        subType: 'labelPoint',
        method: getList,
        params: {
          type: 9,
          size: 1000
        },
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/psk.png',
@@ -590,147 +396,35 @@
          addPopLayers[attrParams.id].addOverlay(divIcon)
        }
      },
      // {
      //   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: '4',
    label: '风险源',
    children: [
      {
        parentId: '4',
        id: '4-1',
        label: '一般',
        id: '3-10',
        label: '洼地',
        type: 'layer',
        subType: 'labelPoint',
        method: getRiskList,
        method: getList,
        params: {
          riskLevel: 1,
          type: 10,
          size: 1000
        },
        showParams: 'category',
        className: 'fxy-ordinary',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-yb.png',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsc.png',
        className: 'xfs-box',
        showPanel: false,
        layerName: 'fxyOrdinary',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          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.riskLevelName || ''}</li>
            <li>行业类别:${attrParams.name || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
        layerName: 'wsc'
      },
      {
        parentId: '4',
        id: '4-2',
        label: '较大',
        id: '3-11',
        label: '闸坝',
        type: 'layer',
        subType: 'labelPoint',
        method: getRiskList,
        method: getList,
        params: {
          riskLevel: 2,
          type: 11,
          size: 1000
        },
        showParams: 'category',
        className: 'fxy-larger',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-jd.png',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/wsc.png',
        className: 'xfs-box',
        showPanel: false,
        layerName: 'fxyLarger',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          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.riskLevelName || ''}</li>
            <li>行业类别:${attrParams.name || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
      {
        parentId: '4',
        id: '4-9',
        label: '暂定',
        type: 'layer',
        subType: 'labelPoint',
        method: getRiskList,
        params: {
          riskLevel: 9,
          size: 1000
        },
        showParams: 'category',
        className: 'fxy-zd',
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy-zd.png',
        showPanel: false,
        layerName: 'fxyZdLarger',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          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),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
        layerName: 'wsc'
      }
    ]
  },
@@ -771,35 +465,7 @@
      panoramaUrl.value = attrParams.url
      panoramaShow.value = true
    }
  },
  {
    id: '8',
    label: '地面全景分布',
    type: 'layer',
    subType: 'labelPoint',
    method: getPanoramaList,
    params: {
      size: 1000,
      remark: '2'
    },
    backgroundIcon: VITE_APP_BASE + 'img/mapicon/qj.png',
    showPanel: false,
    layerName: 'dtqjdwfb',
    incident: (e) => {
      const { attrParams } = e.overlay
      panoramaTitle.value = attrParams.name
      if (
        attrParams.url.indexOf("http://vr.jxpskj.com:180") != -1
      ) {
        attrParams.url = attrParams.url.replace(
          "http://vr.jxpskj.com:180",
          "/panorama"
        )
      }
      panoramaUrl.value = attrParams.url
      panoramaShow.value = true
    }
  },
  }
]
// let modellayer = new DC.VectorLayer("modellayer").addTo(window.$viewer)
@@ -888,7 +554,7 @@
              skipLevelOfDetail: true,
              baseScreenSpaceError: 1024,
              maximumScreenSpaceError: 16, // 数值加大,能让最终成像变模糊
              maximumScreenSpaceError: 128, // 数值加大,能让最终成像变模糊
              skipScreenSpaceErrorFactor: 128,
              skipLevels: 5,
              immediatelyLoadDesiredLevelOfDetail: false,
@@ -916,7 +582,10 @@
          window.$viewer.addLayer(addTileLayers[item.layerName])
          item.method(item.params).then(res => {
            let data = res.data.data.records
            let data = res.data.data.records.filter(i => {
              if ('type' in item.params) return i.type == item.params.type
              return i
            })
            data.filter(i => i.lng && i.lng != '' && i.lat && i.lat != '').forEach(i => {
              let iconEl = ''
@@ -963,9 +632,9 @@
          addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(addTileLayers[item.layerName])
          item.source.features.forEach(i => {
          item.source.geometries.forEach(i => {
            let wall = new DC.Wall(
              i.geometry.coordinates[0].map(d => [...d, 125].join(',')).join(';')
              i.coordinates.map(d => [...d, 125].join(',')).join(';')
            )
            wall.setStyle({
@@ -1139,9 +808,9 @@
// 飞到园区范围
const flyToyqfw = () => {
  window.$viewer.zoomToPosition(new DC.Position(
    115.1021,
    27.2360,
    5000,
    115.4674,
    27.8128,
    7000,
    0,
    -45,
    0
@@ -1167,21 +836,13 @@
  EventBus.emit('restHandleDelChange', `2`)
  EventBus.emit('restHandleDelChange', `3-1`)
  EventBus.emit('restHandleDelChange', `3-2`)
  // 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-1`)
  EventBus.emit('restHandleDelChange', `4-2`)
  EventBus.emit('restHandleDelChange', `4-9`)
  EventBus.emit('restHandleDelChange', `8`)
  EventBus.emit('restHandleDelChange', `3-9`)
  EventBus.emit('restHandleDelChange', `3-10`)
  EventBus.emit('restHandleDelChange', `3-11`)
  destroyPop()
}