From 8e72ebbb44dba3ec5cf6dd3cd2613e6e9aed31ef Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 22 Nov 2024 15:37:33 +0800
Subject: [PATCH] Merge branch 'main' of http://139.196.74.78:10010/r/zhyq/bigScreen

---
 src/views/companyInfo/components/box/unitContent.vue |   88 +++++++++++++++++++------------------------
 1 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/src/views/companyInfo/components/box/unitContent.vue b/src/views/companyInfo/components/box/unitContent.vue
index 5b2b492..c1cdb8d 100644
--- a/src/views/companyInfo/components/box/unitContent.vue
+++ b/src/views/companyInfo/components/box/unitContent.vue
@@ -27,6 +27,7 @@
 const curSelect = ref('')
 
 let addTileLayers = {}
+let addPupoLayers = {}
 onMounted(() => {
     handleCheckChange()
 })
@@ -44,29 +45,42 @@
         }).then(res => {
             let data = res.data.data.records
             data.filter(i => i.lng && i.lng != '' && i.lat && i.lat != '').forEach(i => {
-                let iconEl = ''
-                // {
-                //     iconEl = `<div class="marsBlueGradientPnl">
-                //   <div>${i.name}</div>
-                // </div>`
-                // }
                 let img = image.value.filter(l => i.name.includes(l.label))
                 img = img.length > 0 ? img : image
-                iconEl = `<div class="map-name">${i.name}</div>
-                            <div class="map-icon">
-                            <img src="${img[0].value}">
-                            </div>`
-
+                let iconEl = `<div class="map-name">${i.name}</div>
+                            <div class="map-icon"> <img src="${img[0].value}"> </div>`
                 let divIcon = new DC.DivIcon(
-                    new DC.Position(i.lng, i.lat, 0),
-                    `<div class="public-map-popup  ${'yjc-box'}">
-                    ${iconEl}
-                    </div>`
+                    new DC.Position(i.lng, i.lat, 64),
+                    `<div class="public-map-popup  ${'yjc-box'}"> ${iconEl}  </div>`
                 )
 
                 divIcon.attrParams = i
 
-                let incident = () => { }
+                let 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}" />
+                </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)
+                }
 
                 // if (item.incident) incident = item.incident
 
@@ -85,45 +99,21 @@
     // }
     // })
 }
-
-// 获取下拉字典
-// const getDictData = (code) => {
-//     const param = {
-//         code: code,
-//     }
-//     getDictionary(param).then((res) => {
-//         resData.data = res.data.data.map(item => {
-//             return {
-//                 type: item.sort,
-//                 label: item.dictValue,
-//                 value: item.dictKey
-//             }
-//         })
-
-//         tabClick(resData.data[0])
-//     })
-// }
-
-// const tabClick = (item) => {
-//     handleCheckChange(item)
-//     // curSelect.value = item.value
-// }
-
-// const showOn = computed(() => (item) => {
-//     if (curSelect.value == item.value) {
-//         return true
-//     }
-//     return false
-// })
-
-// getDictData("emergency_space_type")
-
+// 销毁
+function destroy() {
+    let arr = Object.keys(addPupoLayers)
+    arr.filter(i => i != 'hgyq').forEach(i => {
+        addPupoLayers[i] && window.$viewer.removeLayer(addPupoLayers[i])
+    })
+    addPupoLayers = {}
+}
 onUnmounted(() => {
     console.log('leftContainer unmounted***********************')
     let arr = Object.keys(addTileLayers)
     arr.forEach(i => {
         addTileLayers[i] && window.$viewer.removeLayer(addTileLayers[i])
     })
+    destroy()
 })
 </script>
 

--
Gitblit v1.9.3