智慧园区前端大屏
linwe
2024-11-22 5221bb4832912e7e494b76e4fdf64eb0c98fce50
src/pages/layout/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-11-22 14:52:56
 * @LastEditTime: 2024-11-22 15:37:11
 * @FilePath: \bigScreen\src\pages\layout\components\scomponents\layersControl.vue
 * @Description:
 *
@@ -74,7 +74,7 @@
const { VITE_APP_BASE } = import.meta.env
let indexPoint = ref(['1'])
let indexPoint = ref(['5', '7', '1'])
const treeRef = ref(null)
const Cesium = DC.getLib('Cesium')
@@ -169,7 +169,7 @@
          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          window.$viewer.addLayer(addPupoLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl">
            <div>${attrParams.fullName}</div>
            <div>${attrParams.fullName}</div>
            <img src="${attrParams.imageUrl}" />
                </div>`
          let divIcon = new DC.DivIcon(
@@ -456,6 +456,28 @@
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy.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])
          let iconEl = `<div class="marsBlueGradientPnl">
            <li>${attrParams.firmName || ''}</li>
            <li>${attrParams.riskLevelName || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, 64),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroy()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
        }
      },
      {
        id: '4-2',
@@ -472,6 +494,51 @@
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy.png',
        showPanel: false,
        layerName: 'fxyLarger',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          destroy()
          // if (!attrParams.imageUrl) {
          //   return
          // }
          // addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          // window.$viewer.addLayer(addPupoLayers[attrParams.name])
          // let iconEl = `<div class="marsBlueGradientPnl">
          //         <div>${attrParams.fullName}</div>
          //         <img src="${attrParams.imageUrl}" width="160" height="160" />
          //       </div>`
          // let divIcon = new DC.DivIcon(
          //   new DC.Position(attrParams.lng, attrParams.lat, 64),
          //   `<div class="public-map-popup-two">
          //           ${iconEl}
          //         </div>`
          // )
          // let incident = () => {
          //   destroy()
          // }
          // divIcon.on(DC.MouseEventType.CLICK, incident)
          // addPupoLayers[attrParams.name].addOverlay(divIcon)
          // 删除
          destroy()
          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          window.$viewer.addLayer(addPupoLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl">
            <li>${attrParams.firmName || ''}</li>
            <li>${attrParams.riskLevelName || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, 64),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroy()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
        }
      }
    ]
  },
@@ -598,7 +665,6 @@
        } else {
          window.addTileLayers[item.layerName].forEach(i => i.show = true)
        }
        // window.$viewer.flyTo(window.addTileLayers[item.layerName][0])
      } else if (item.subType == 'labelPoint') {
        if (!window.addTileLayers[item.layerName]) {
          window.addTileLayers[item.layerName] = new DC.HtmlLayer(item.layerName)
@@ -660,7 +726,7 @@
            wall.setStyle({
              material: new DC.WallTrailMaterialProperty({
                color: Cesium.Color.fromBytes(0, 123, 255, 180),
                speed: 10
                speed: 8
              })
            })
            window.addTileLayers[item.layerName].addOverlay(wall)
@@ -668,12 +734,15 @@
        } else {
          window.addTileLayers[item.layerName].show = true
        }
        // 飞到园区范围
        window.$viewer.flyTo(addTileLayers[item.layerName])
        // console.log('flyToyqfw********2222222222*******************************', addTileLayers[item.layerName])
      } else if (item.subType == 'geojsonPipe') {
        if (!window.addTileLayers[item.layerName]) {
          window.addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(window.addTileLayers[item.layerName])
          function computeCircle (radius) {
          function computeCircle(radius) {
            var positions = []
            for (var i = 0; i < 360; i++) {
              var radians = DC.Math.toRadians(i)
@@ -716,7 +785,7 @@
  })
}
function findObjectById (data, id) {
function findObjectById(data, id) {
  // 遍历数据数组
  for (let i = 0; i < data.length; i++) {
    const item = data[i]
@@ -763,8 +832,15 @@
  handleCheckChange([findObjectById(data, key)])
}
// 飞到园区范围
const flyToyqfw = () => {
  console.log('flyToyqfw***************************************', addTileLayers['yqfw'])
  window.$viewer.flyTo(addTileLayers['yqfw'])
}
EventBus.on('restHandleCheckChange', restHandleCheckChange)
EventBus.on('restHandleDelChange', restHandleDelChange)
EventBus.on('flyToyqfw', flyToyqfw)
onMounted(() => {
  handleCheckChange(data.filter(i => indexPoint.value.includes(i.id)))
@@ -775,7 +851,7 @@
// });
// 销毁
function destroy () {
function destroy() {
  let arr = Object.keys(addPupoLayers)
  arr.filter(i => i != 'hgyq').forEach(i => {
    addPupoLayers[i] && window.$viewer.removeLayer(addPupoLayers[i])