Эх сурвалжийг харах

加载tif并实现左右分屏加载前后时相并完成删除与调整

lkk 5 сар өмнө
parent
commit
467ad995d1

+ 1 - 26
src/views/farmlandProtection/components/hcxx.vue

@@ -74,20 +74,6 @@ export default {
     return {
       imgUrl: "",
       monitorList: [],
-      monitorImg: [
-        {
-          imgUrl:
-            "https://img2.baidu.com/it/u=882190421,2711411099&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1067",
-        },
-        {
-          imgUrl:
-            "http://img2.baidu.com/it/u=516755055,1384417278&fm=253&app=138&f=JPEG?w=800&h=1067",
-        },
-        {
-          imgUrl:
-            "http://img0.baidu.com/it/u=1366170349,307387023&fm=253&app=138&f=JPEG?w=800&h=1067",
-        },
-      ],
       primitive: null,
       selectId: null,
       primitivesArray: [],
@@ -100,15 +86,7 @@ export default {
   },
   computed: {},
   mounted() {
-    this.$nextTick(() => {
-      // this.aaa();
-      // this.ddd();
-      // this.imgUrl =
-      //   "https://b0.bdstatic.com/ugc/Gr0RkpztmAdvrxnS4n54Iw49d04e3484c9bb1a11f03b38a819d893.jpg@h_1280";
-    });
-    // http://192.168.60.2:8080/file/upload/attachment
-    // this.imgUrl = window.axiosURI + "/file/upload/attachment";
-    this.inputAction();
+    // this.inputAction();
   },
   methods: {
     inputAction() {
@@ -357,10 +335,7 @@ export default {
             this.hcObj = res.data;
             this.monitorList.forEach((item, i) => {
               item.name = res.data.dcry;
-              console.log(item.imagerPath,'item.imagerPath111');
-              // item.imagerPath = this.monitorImg[i].imgUrl;
               item.imagerPath = window.axiosURI + "/file/upload/attachment" + item.imagerPath;
-              console.log(item.imagerPath,'item.imagerPath');
               this.ddd(item);
               this.idArr.push(item.id);
             });

+ 59 - 40
src/views/farmlandProtection/components/tbDetails.vue

@@ -2,11 +2,12 @@
   <div class="ghzc">
     <div class="btn" v-if="splitScreen">
       <span class="sx jcbh">前后影像对比:{{ detailObj.jcbh }}</span>
+      <span class="sx tc" @click="outSce">退出</span>
       <!-- <el-button @click="drawer = true">打开抽屉</el-button> -->
       <span class="sx qsx">前时相:{{ detailObj.qsx }}</span>
       <span class="sx hsx">后时相:{{ detailObj.hsx }}</span>
     </div>
-    <div class="sm-panel sm-function-module-query" v-drag>
+    <div class="sm-panel sm-function-module-query" v-drag v-if="!splitScreen">
       <div class="sm-panel-header">
         <span>图斑详情</span>
         <i class="el-icon-close" @click="closeBox"></i>
@@ -46,6 +47,8 @@ import {
   useRoller,
 } from "@/utils/MapHelper/map.js";
 import { getTiffPath } from "@/api/ghss/jctb.js";
+import { loadGeoJSON } from "@/utils/MapHelper/help.js";
+let layerSources = {};
 export default {
   props: {
     detailObj: {
@@ -75,6 +78,7 @@ export default {
     closeBox() {
       if (this.splitScreen) {
         this.splitScreen = false;
+
         // this.onClick(false);
       }
       viewer.entities.removeAll();
@@ -82,6 +86,13 @@ export default {
       this.$emit("updateParent", "emitImgIndex", -1);
       this.$emit("updateParent", "allShow", true);
     },
+    outSce() {
+      let mul = "NONE";
+      scene.multiViewportMode = Cesium.MultiViewportMode[mul];
+      this.remove();
+      this.splitScreen = false;
+      this.$emit("updateParent", "allShow", true);
+    },
     onClickjl(show) {
       if (show) {
         let jl = {
@@ -137,34 +148,34 @@ export default {
     },
     clickOpen() {
       getTiffPath(this.detailObj.qsxtif).then((res) => {
-        this.remove();
-        console.log(res.data,'res.data')
+        // this.remove();
+        if (res.data.pngenvelope) {
+          this.getEntities(
+            this.detailObj.jcbh,
+            res.data.pngpath,
+            res.data.pngenvelope,
+            0
+          );
+        }
+      });
+      getTiffPath(this.detailObj.hsxtif).then((res) => {
         if (res.data.pngenvelope) {
           this.getEntities(
             this.detailObj.jcbh,
             res.data.pngpath,
-            res.data.pngenvelope
+            res.data.pngenvelope,
+            1
           );
         }
       });
-      // getTiffPath(this.detailObj.hsxtif).then((res) => {
-      //   this.remove();
-      //   if (res.data.pngenvelope) {
-      //     this.getEntities(
-      //       this.detailObj.jcbh,
-      //       res.data.pngpath,
-      //       res.data.pngenvelope
-      //     );
-      //   }
-      // });
 
       this.$emit("updateParent", "allShow", false);
       this.splitScreen = true;
     },
 
-    getEntities(id, url, position) {
-      // let mul =  "HORIZONTAL";
-      // viewer.scene.multiViewportMode = Cesium.MultiViewportMode[mul];
+    getEntities(id, url, position, type) {
+      let mul = "HORIZONTAL";
+      scene.multiViewportMode = Cesium.MultiViewportMode[mul];
       let imageUrl = "";
       let posArr = position;
       imageUrl = window.axiosURI + "/file/upload/attachment" + url;
@@ -174,30 +185,33 @@ export default {
         repeat: new Cesium.Cartesian2(1.0, 1.0), // 控制图像重复,这里设置为不重复
         transparent: true, // 如果图像有透明通道,设置为true
       });
-
-      // 创建一个矩形实体并应用材质
-      const rectangleEntity = viewer.entities.add({
-        name: "Image Overlay",
-        id: id,
-        rectangle: {
-          coordinates: Cesium.Rectangle.fromDegrees(
-            posArr[0],
-            posArr[1],
-            posArr[2],
-            posArr[3]
-          ), // 设置矩形的经纬度范围
-          material: imageMaterial,
-        },
+      loadGeoJSON(this.detailObj.geom, "#ff0000", { isfly: true }, (data) => {
+        data.entities.add({
+          name: "Image Overlay",
+          id: id + type,
+          rectangle: {
+            coordinates: Cesium.Rectangle.fromDegrees(
+              posArr[0],
+              posArr[1],
+              posArr[2],
+              posArr[3]
+            ), // 设置矩形的经纬度范围
+            material: imageMaterial,
+          },
+        });
+        layerSources[id + type] = data;
+        if (type == 0) {
+          data.setVisibleInViewport(1, false);
+        } else {
+          data.setVisibleInViewport(0, false);
+        }
       });
-      this.idArr.push(rectangleEntity.id);
-      // rectangleEntity.setVisibleInViewport(1, false);
-      // 调整视图以查看实体
-      viewer.zoomTo(rectangleEntity);
+      this.idArr.push(id + type);
     },
     remove() {
       if (this.idArr.length != 0) {
         this.idArr.forEach((item) => {
-          viewer.entities.removeById(item);
+          viewer.dataSources.remove(layerSources[item]);
         });
       }
     },
@@ -207,11 +221,13 @@ export default {
       this.$emit("updateParent", "imgIndex", val);
       this.$emit("updateParent", "imgList", this.emitImgList);
     },
-    splitScreen(val) {
-      this.onClick(val);
-    },
+    // splitScreen(val) {
+    //   this.onClick(val);
+    // },
+  },
+  beforeDestroy() {
+    this.remove();
   },
-  beforeDestroy() {},
 };
 </script>
 
@@ -274,6 +290,9 @@ export default {
   .jcbh {
     left: 3vw;
   }
+  .tc {
+    left: 21.5vw;
+  }
 }
 .dbBtn {
   width: 136px;

+ 3 - 1
src/views/farmlandProtection/components/tbqd.vue

@@ -200,7 +200,10 @@ export default {
           "#ff0000",
           { isfly: true, sw: 5 },
           (data) => {
+            let mul = "HORIZONTAL";
+            scene.multiViewportMode = Cesium.MultiViewportMode[mul];
             layerSources["h_" + item.index] = data;
+            data.setVisibleInViewport(1, false);
             data.entities.values.forEach((entity) => {
               entity.properties = item;
             });
@@ -247,7 +250,6 @@ export default {
         ...params,
       };
       let data = await QueryList(obj);
-      console.log(data);
       data.data.map((res) => {
         if (res.geom) {
           res.geom = wellknown.parse(res.geom.split(";")[1]);

+ 1 - 9
src/views/farmlandProtection/jctb/index.vue

@@ -87,7 +87,7 @@
       ref="tbDetails"
       @updateParent="changeData"
       :detailObj="detailObj"
-      v-show="isShowTb"
+      v-if="isShowTb"
     ></tbDetails>
     <div class="imgRemove" v-drag v-show="imgIndex != -1">
       <div class="sm-panel-header">
@@ -122,14 +122,6 @@
         </el-carousel>
       </div>
     </div>
-    <!-- <div class="tiffBox" id="fullscreen-div">
-      <div class="sm-panel-header">
-        <span>前后影像对比</span>
-        <i class="el-icon-full-screen" @click="fullScreen"></i>
-        <i class="el-icon-aim" @click="aimScreen"></i>
-      </div>
-      <img src="../components//u385.jpg"/>
-    </div> -->
   </div>
 </template>