瀏覽代碼

监测图斑上图清除和定位图斑清除

maxiaoxiao 2 周之前
父節點
當前提交
0477e52d90
共有 1 個文件被更改,包括 23 次插入8 次删除
  1. 23 8
      src/views/farmlandProtection/components/tbqd.vue

+ 23 - 8
src/views/farmlandProtection/components/tbqd.vue

@@ -139,7 +139,7 @@
 import * as wellknown from "wellknown";
 import * as turf from "@turf/turf";
 import { QueryOne, QueryList } from "@/api/cockpitNew";
-import { loadGeoJSON } from "@/utils/MapHelper/help.js";
+import { loadGeoJSON, removeGeoJSON } from "@/utils/MapHelper/help.js";
 import { JctbList, envelope, getJctbInfo } from "@/api/ghss/jctb.js";
 let layerSources = {};
 export default {
@@ -186,20 +186,34 @@ export default {
         this.tableData = res.rows;
         this.total = res.total;
         let ewkt = [];
+        removeGeoJSON("farmlandjc");
         res.rows.forEach((item) => {
           ewkt.push(item.geom);
-          if (item.geom) loadGeoJSON(item.geom, "#55A1E3", {});
+          if (item.geom)
+            loadGeoJSON(
+              item.geom,
+              "#55A1E3",
+              {},
+              (data) => (data.name = "farmlandjc")
+            );
         });
         envelope({ ewkt }).then((res) => {
-          loadGeoJSON(res.data, "#55A1E3", {
-            isfly: true,
-            fill_a: 0.01,
-            sw: 0.001,
-          });
+          loadGeoJSON(
+            res.data,
+            "#55A1E3",
+            {
+              isfly: true,
+              fill_a: 0.01,
+              sw: 0.001,
+            },
+            (data) => (data.name = "farmlandjc")
+          );
         });
       });
     },
     handleClick(item) {
+      removeGeoJSON("farmlandjch");
+      // viewer.dataSources.remove(layerSources[this.tempdataLayerId]);
       if (!item.geom) {
         this.$message.warning("缺少定位图斑");
       } else {
@@ -210,6 +224,7 @@ export default {
           { isfly: true, sw: 5 },
           (data) => {
             let mul = "HORIZONTAL";
+            data.name = "farmlandjch";
             // scene.multiViewportMode = Cesium.MultiViewportMode[mul];
             layerSources["h_" + item.index] = data;
             // data.setVisibleInViewport(1, false);
@@ -274,7 +289,7 @@ export default {
         this.initNew();
       },
       deep: true,
-      immediate: true,
+      // immediate: true,
     },
     // input(newVal, oldVal){
     //   this.initNew();