智慧园区前端大屏
linwe
2024-12-03 02aeefab8a600c0e8c0dc9a1507925f38d633c12
src/pages/map/components/scomponents/layersControl.vue
@@ -50,7 +50,7 @@
</template>
<script setup>
let addPupoLayers = {}
let addPopLayers = {}
let addTileLayers = {}
let tileLayers = new DC.TilesetLayer('tileLayers')
window.$viewer.addLayer(tileLayers)
@@ -168,12 +168,12 @@
        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>`
@@ -184,10 +184,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
      {
@@ -207,12 +207,12 @@
        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" />
@@ -224,10 +224,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
@@ -298,12 +298,12 @@
        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" />
@@ -315,10 +315,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
@@ -339,12 +339,12 @@
        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" />
@@ -356,10 +356,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
@@ -380,12 +380,12 @@
        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" />
@@ -397,10 +397,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
@@ -490,11 +490,13 @@
        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),
@@ -503,10 +505,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      },
      {
@@ -527,11 +529,13 @@
        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),
@@ -540,10 +544,10 @@
                  </div>`
          )
          let incident = () => {
            destroy()
            destroyPop()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
          addPopLayers[attrParams.name].addOverlay(divIcon)
        }
      }
    ]
@@ -911,6 +915,7 @@
EventBus.on('restHandleCheckChange', restHandleCheckChange)
EventBus.on('restHandleDelChange', restHandleDelChange)
EventBus.on('flyToyqfw', flyToyqfw)
EventBus.on('destroyPop', destroyPop)
onMounted(() => {
  handleCheckChange(data.filter(i => indexPoint.value.includes(i.id)))
@@ -941,7 +946,7 @@
  EventBus.emit('restHandleDelChange', `4-1`)
  EventBus.emit('restHandleDelChange', `4-2`)
  EventBus.emit('restHandleDelChange', `8`)
  destroy()
  destroyPop()
}
// const sharedData = computed(() => pointStore.sharedData);
@@ -957,14 +962,14 @@
)
// 销毁
function destroy () {
  let arr = Object.keys(addPupoLayers)
function destroyPop () {
  let arr = Object.keys(addPopLayers)
  arr.filter(i => i != 'hgyq').forEach(i => {
    addPupoLayers[i] && window.$viewer && window.$viewer.removeLayer(addPupoLayers[i])
    addPupoLayers[i] = null
    delete addPupoLayers[i]
    addPopLayers[i] && window.$viewer && window.$viewer.removeLayer(addPopLayers[i])
    addPopLayers[i] = null
    delete addPopLayers[i]
  })
  addPupoLayers = {}
  addPopLayers = {}
}
onUnmounted(() => {
@@ -988,8 +993,8 @@
    tileLayers = null
  }
  // 弹窗销毁
  destroy()
  addPupoLayers = null
  destroyPop()
  addPopLayers = null
  EventBus.off('restHandleCheckChange', restHandleCheckChange)
  EventBus.off('restHandleDelChange', restHandleDelChange)