Przeglądaj źródła

加载tif文件

lkk 9 miesięcy temu
rodzic
commit
2292efabb7
1 zmienionych plików z 27 dodań i 11 usunięć
  1. 27 11
      src/views/remote/farmland/index.vue

+ 27 - 11
src/views/remote/farmland/index.vue

@@ -102,6 +102,8 @@ import ImageLayer from "ol/layer/Image";
 import ImageStatic from "ol/source/ImageStatic";
 import Draw from "ol/interaction/Draw";
 import GeoJSON from "ol/format/GeoJSON";
+import GeoTIFF from "ol/source/GeoTIFF";
+import WebGLTile from "ol/layer/WebGLTile";
 export default {
   components: {
     MapView,
@@ -119,12 +121,6 @@ export default {
       direction: "rtl",
 
       tableData: [],
-      // pcsjObj:{
-      //   name:'f52d8b03a7214d9098ca44a7ea641d9b',
-      //   spotsnumber:0,
-      //   spotsarea:0,
-
-      // },
       newObj: {
         name: "f52d8b03a7214d9098ca44a7ea641d9b",
         spotsnumber: 0,
@@ -136,14 +132,10 @@ export default {
   },
   mounted() {
     console.log(this.$route.query);
-    // this.addGeoJson()
     // 绑定事件,编写回调函数
     this.$nextTick(() => {
       getPcsj(this.$route.query.id).then((response) => {
-        console.log(response, "response");
         this.newObj = response.data;
-        // this.open = true;
-        // this.title = "修改监管批次数据";
       });
       this.getList();
     });
@@ -153,10 +145,34 @@ export default {
     tableClick(row) {
       let url = this.newObj.proxypath + row.hsxtif;
       console.log(row, "-----", url);
+      const source = new GeoTIFF({
+        sources: [
+          {
+            // url: url,
+            url: "http://192.168.60.4:9201/spotfile/64018120240902/DDOM/6401812024070108270001DDOM.tif",
+            nodata: 0,
+            imageExtent: [38.207187, 106.672957, 38.21268, 106.67845],
+            projection: "EPSG:4326",
+          },
+        ],
+      });
+      const layer = new WebGLTile({
+        source: source,
+      });
+
+      // var layer = new ImageLayer({
+      //   source: new ImageStatic({
+      //     // url: 'path/to/your.tif',
+      //     url: 'http://192.168.60.4:9201/spotfile/64018120240902/DDOM/6401812024070108270001DDOM.tif',
+      //     // imageExtent: [minX, minY, maxX, maxY],
+      //     imageExtent: [38.207187, 106.672957, 38.212680,106.678450, ],
+      //     projection: 'EPSG:4326'
+      //   })
+      // });
+      window.map.addLayer(layer);
     },
     getList() {
       listPcsjXQList(this.queryParams).then((response) => {
-        console.log(response, "response1111111");
         this.tableData = response.rows;
         this.total = response.total;
         // this.open = true;