Prechádzať zdrojové kódy

清除未覆盖区域标记面2

qinhouyu 1 rok pred
rodič
commit
e498bf2d0b
2 zmenil súbory, kde vykonal 34 pridanie a 31 odobranie
  1. 30 17
      src/components/supermap-2.5d.vue
  2. 4 14
      src/views/monitor.vue

+ 30 - 17
src/components/supermap-2.5d.vue

@@ -54,7 +54,7 @@
         markerboxEntity: [], //地图落点实体
         markerboxEntityRadius: [], //地图落点实体
         connectBoxEntity: null, //地图线实体
-        graphicsBoxEntity: null, //地图面实体
+        graphicsBoxEntity: [], //地图面实体
         connectBoxEntityTwo: null, //地图线实体
         timer: null,
         /*************************原地图属性*********************/
@@ -346,9 +346,11 @@
       },
       //移除之前添加的面
       clearG() {
-        if (this.graphicsBoxEntity != null) {
-          this.viewer.entities.remove(this.graphicsBoxEntity)
-          this.graphicsBoxEntity = null
+        if (this.graphicsBoxEntity != null && this.graphicsBoxEntity.length > 0) {
+          for (let i = 0; i < this.graphicsBoxEntity.length; i++) {
+            this.viewer.entities.remove(this.graphicsBoxEntity[i])
+          }
+          this.graphicsBoxEntity = []
         }
       },
       superMapInfo(index) {
@@ -943,35 +945,46 @@
       /**
        * 地图画线(贴地)
        */
-      setConnectTwoList(connectList, color, withAlpha) {
+      setGraphicsList(graphicsList, color, withAlpha) {
         let that = this
         //Cesium.Color.fromCssColorString('#67ADDF')   16进制颜色设置
         let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
-        that.connectBoxEntityTwo = that.viewer.entities.add({
-          Type: 'Polyline',
-          polyline: {
-            positions: Cesium.Cartesian3.fromDegreesArray(connectList),
+        let graphicsBoxEntity = that.viewer.entities.add({
+          polygon: {
+            hierarchy: Cesium.Cartesian3.fromDegreesArray(graphicsList),
             clampToGround: true, //贴地 true,不贴地  false
             width: 5,
             material: material
           }
         })
+        that.graphicsBoxEntity.push(graphicsBoxEntity);
       },
       /**
        * 地图图形(贴地)
        */
-      setGraphicsList(graphicsList, color, withAlpha) {
+      setGraphicsListMultiple(graphicsList, color, withAlpha) {
         let that = this
         //Cesium.Color.fromCssColorString('#67ADDF')   16进制颜色设置
         let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
-        that.graphicsBoxEntity = that.viewer.entities.add({
-          polygon: {
-            hierarchy: Cesium.Cartesian3.fromDegreesArray(graphicsList),
-            clampToGround: true, //贴地 true,不贴地  false
-            width: 5,
-            material: material
+        for (let i = 0; i < graphicsList.length; i++) {
+          if (graphicsList[i].latLngs != null && graphicsList[i].latLngs != "") {
+            let jsonToArr = JSON.parse(graphicsList[i].latLngs);
+            const arr = []
+            for (let j = 0; j < jsonToArr.length; j++) {
+              arr.push(jsonToArr[j].lng)
+              arr.push(jsonToArr[j].lat)
+            }
+            let graphicsBoxEntity = that.viewer.entities.add({
+              polygon: {
+                hierarchy: Cesium.Cartesian3.fromDegreesArray(arr),
+                clampToGround: true, //贴地 true,不贴地  false
+                width: 5,
+                material: material
+              }
+            })
+            that.graphicsBoxEntity.push(graphicsBoxEntity);
           }
-        })
+        }
       }
     },
   }

+ 4 - 14
src/views/monitor.vue

@@ -31,7 +31,7 @@
                     <h5>传感器</h5>
                   </div>
                 </div>
-                <div class="icon-con w-33 m-btm-no" :class="{on:onLa}">
+                <div class="icon-con w-33 m-btm-no" :class="{on:onLa}" @click="$refs.supermap.clearG()">
                   <div class="icon icon-dot"></div>
                   <div class="icon-text">
                     <h6>{{ loudspeakerNum }}</h6>
@@ -297,17 +297,7 @@
         let that = this;
         notCoverPlaces(deptId).then((res) => {
           if (res.data != null && Array.isArray(res.data)) {
-            for (let i = 0; i < res.data.length; i++) {
-              if (res.data[i].latLngs != null && res.data[i].latLngs != "") {
-                let jsonToArr = JSON.parse(res.data[i].latLngs);
-                const arr = []
-                for (let j = 0; j < jsonToArr.length; j++) {
-                  arr.push(jsonToArr[j].lng)
-                  arr.push(jsonToArr[j].lat)
-                  that.$refs.supermap.setGraphicsList(arr, "rgba(23,22,22,0)", 0.8);
-                }
-              }
-            }
+            that.$refs.supermap.setGraphicsListMultiple(res.data,"rgba(23,22,22,0)", 0.8);
           }
         })
       },
@@ -449,7 +439,6 @@
         this.placeholderMsg = "请输入摄像头名称"
         this.selectDeviceType()
         this.getNotCoverPlaces(this.deptId);
-
       },
       laClick() {
         this.onLa = true
@@ -459,6 +448,7 @@
         this.placeholderMsg = "请输入云广播名称"
         this.deptId = Cookies.get("deptId")
         this.getDlblistBydeptId()
+        this.$refs.supermap.clearG();
       },
       chuanClick() {
         this.onLa = false
@@ -468,7 +458,7 @@
         this.placeholderMsg = "请输入传感器名称"
         this.deptId = Cookies.get("deptId")
         this.getMonitorDeviceAndDataList()
-
+        this.$refs.supermap.clearG();
       },
       chuanSet() {
         let that = this