From a92fa5ec4d415ccc42f8c3b7eae7d07cc8418889 Mon Sep 17 00:00:00 2001
From: Surpriseplus <845948745@qq.com>
Date: 星期四, 16 二月 2023 16:33:11 +0800
Subject: [PATCH] 1

---
 src/components/MapView/mapMenuPop.vue |   95 +++++++++++++++++++++++++----------------------
 1 files changed, 51 insertions(+), 44 deletions(-)

diff --git a/src/components/MapView/mapMenuPop.vue b/src/components/MapView/mapMenuPop.vue
index c91d74c..dde75e2 100644
--- a/src/components/MapView/mapMenuPop.vue
+++ b/src/components/MapView/mapMenuPop.vue
@@ -467,7 +467,20 @@
       this.listdata.name = null;
       this.option = [];
     },
+    clearQuerInfo() {
+      if (this.$store.state.queryInfo.length != 0) {
+        for (var i in this.$store.state.queryInfo) {
+          sgworld.Viewer.entities.remove(this.$store.state.queryInfo[i]);
+        }
+        this.$store.state.queryInfo = [];
+        if (this.$store.state.primitLayer != null) {
+          sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
+          this.$store.state.primitLayer = null;
+        }
+      }
+    },
     setTableAll() {
+      this.clearQuerInfo();
       this.signGetPublicKey();
       this.startTableMssage();
       this.listdata.wkt = this.$store.state.mapMenuShpFile;
@@ -628,13 +641,7 @@
       this.showAllImage(data.result);
     },
     async showAllImage(res) {
-      if (window.Viewer.scene.primitives.length != null) {
-        window.Viewer.scene.primitives.removeAll();
-      }
-      if (this.$store.state.primitLayer != null) {
-        sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
-        this.$store.state.primitLayer = null;
-      }
+
       for (var i in res) {
         var param = {
           gid: res[i].gid,
@@ -647,7 +654,7 @@
         var val1 = decr(data.result);
         if (val1) {
           var wkt = this.$wkt.parse(val1);
-          this.getprimitiLayer(wkt);
+          // this.getprimitiLayer(wkt);
           this.primitivesAddLayer(wkt);
         }
       }
@@ -662,6 +669,7 @@
       }
     },
     primitivesAddLayer(res) {
+      debugger
       switch (res.type) {
         case "Point":
           var val = Cesium.Cartesian3.fromDegrees(
@@ -669,34 +677,41 @@
             res.coordinates[1],
             200
           );
-          this.$store.state.primitLayer.add({
+          var point = Viewer.entities.add({
             position: val,
-            image: SmartEarthRootUrl + "Workers/image/mark.png",
+            billboard: {
+              // 鍥惧儚鍦板潃锛孶RI鎴朇anvas鐨勫睘鎬�
+              image: SmartEarthRootUrl + "Workers/image/mark.png",
+              // 澶у皬鏄惁浠ョ背涓哄崟浣�
+              sizeInMeters: false,
+              // 鐩稿浜庡潗鏍囩殑鍨傜洿浣嶇疆
+              verticalOrigin: Cesium.VerticalOrigin.CENTER,
+              // 鐩稿浜庡潗鏍囩殑姘村钩浣嶇疆
+              horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
+              // 搴旂敤浜庡浘鍍忕殑缁熶竴姣斾緥銆傛瘮渚嬪ぇ浜庝細1.0鏀惧ぇ鏍囩锛岃�屾瘮渚嬪皬浜庝細1.0缂╁皬鏍囩銆�
+              scale: 1.0,
+              // 鏄惁鏄剧ず
+              show: true
+            }
           });
+          this.$store.state.queryInfo.push(point)
           break;
+        case "LineString":
         case "MultiLineString":
           var line = res.coordinates[0];
           var std = [];
           for (var i in line) {
             std.push(line[i][0], line[i][1]);
           }
-          var instance = new Cesium.GeometryInstance({
-            geometry: new Cesium.GroundPolylineGeometry({
+          var polyline = Viewer.entities.add({
+            polyline: {
               positions: Cesium.Cartesian3.fromDegreesArray(std),
-              width: 4.0,
-            }),
-            attributes: {
-              color: Cesium.ColorGeometryInstanceAttribute.fromColor(
-                new Cesium.Color(1.0, 0.0, 0.0, 0.3)
-              ),
-            },
-          });
-          window.Viewer.scene.primitives.add(
-            new Cesium.GroundPolylinePrimitive({
-              geometryInstances: instance,
-              appearance: new Cesium.PolylineColorAppearance(),
-            })
-          );
+              width: 5,
+              material: new Cesium.Color(1.0, 0.0, 0.0, 0.3),
+              clampToGround: true,
+            }
+          })
+          this.$store.state.queryInfo.push(polyline)
           break;
         case "MultiPolygon":
           var val = res.coordinates[0][0];
@@ -704,24 +719,16 @@
           for (var i in val) {
             std.push(val[i][0], val[i][1]);
           }
-          var primitive = new Cesium.GroundPrimitive({
-            //璐村湴鐨刾rimitive
-            geometryInstances: new Cesium.GeometryInstance({
-              geometry: new Cesium.PolygonGeometry({
-                //鏀寔CircleGeometry锛孋orridorGeometry锛孍llipseGeometry锛孯ectangleGeometry
-                polygonHierarchy: new Cesium.PolygonHierarchy(
-                  Cesium.Cartesian3.fromDegreesArray(std)
-                ),
-              }),
-              attributes: {
-                color: Cesium.ColorGeometryInstanceAttribute.fromColor(
-                  new Cesium.Color(1.0, 0.0, 0.0, 0.3)
-                ),
-              },
-            }),
-            appearance: Cesium.EllipsoidSurfaceAppearance(),
-          });
-          window.Viewer.scene.primitives.add(primitive);
+          var entity = Viewer.entities.add({
+            polygon: {
+              hierarchy: Cesium.Cartesian3.fromDegreesArray(std),
+              //height : 100000,
+              material: new Cesium.Color(1.0, 0.0, 0.0, 0.3),
+              outline: true,
+              outlineColor: new Cesium.Color(1.0, 0.0, 0.0, 0.3),
+            }
+          })
+          this.$store.state.queryInfo.push(entity)
           break;
       }
     },

--
Gitblit v1.9.3