From bc8f0b5301b4a63ff4ddd90bb7732c01bdae3a1a Mon Sep 17 00:00:00 2001
From: 584911253@qq.com <584911253@qq.com>
Date: 星期四, 02 三月 2023 17:52:16 +0800
Subject: [PATCH] 属性点击事件

---
 src/components/MapView/mapSpacePop.vue |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/components/MapView/mapSpacePop.vue b/src/components/MapView/mapSpacePop.vue
index 3beea60..c08795a 100644
--- a/src/components/MapView/mapSpacePop.vue
+++ b/src/components/MapView/mapSpacePop.vue
@@ -383,7 +383,7 @@
           this.$store.state.primitLayer = null;
         }
         var wkt = this.$wkt.parse(val1);
-        this.setMapLoaction(wkt);
+        this.setMapLoaction(wkt,row);
       }
     },
     handleSizeChange(val) {
@@ -394,7 +394,7 @@
       this.listdata.pageIndex = val;
       this.getSpaceTableLayer();
     },
-    setMapLoaction(res) {
+    setMapLoaction(res,properties) {
       if (this.$store.state.primitLayer != null) {
         sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
         // this.$store.state.primitLayer = null;
@@ -409,6 +409,8 @@
 
         );
         this.$store.state.primitLayer = Viewer.entities.add({
+          properties:properties,
+          tag : "properties_point",
           position: val,
           billboard: {
             // 鍥惧儚鍦板潃锛孶RI鎴朇anvas鐨勫睘鎬�
@@ -429,6 +431,28 @@
         this.$store.state.primitLayer.billboard.disableDepthTestDistance = Number.POSITIVE_INFINITY;
 
         sgworld.Navigate.flyToObj(this.$store.state.primitLayer)
+
+        window.propertieshandler = new Cesium.ScreenSpaceEventHandler(
+            sgworld.Viewer.scene.canvas
+        );
+        window.propertieshandler.setInputAction(event => {
+          let pick = sgworld.Viewer.scene.pick(event.position);
+          // debugger;
+          if (pick && pick.id && pick.id.tag == "properties_point") {
+            this.$store.state.propertiesFlag = '1';
+            let properties = pick.id.properties;
+            let propertyNames = pick.id.properties.propertyNames;
+            let obj = {};
+            this.attributeData.forEach(item => {
+              propertyNames.forEach(itemElement => {
+                if (itemElement == item.field){
+                  obj[item.alias] = properties[itemElement]._value
+                }
+              })
+            })
+            this.$store.state.propertiesInfo = obj;
+          }
+        }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 
       } else if (res.type == 'MultiPolygon' || res.type == 'LineString') {
         var val = res.coordinates[0][0];
@@ -464,6 +488,9 @@
       }
     },
   },
+  destroyed() {
+    this.$store.state.propertiesFlag = null;
+  }
 };
 </script>
 

--
Gitblit v1.9.3