瀏覽代碼

删除图斑

maxiaoxiao 9 月之前
父節點
當前提交
c3f58fb50b
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/views/remote/farmland/index.vue

+ 12 - 0
src/views/remote/farmland/index.vue

@@ -147,6 +147,8 @@ export default {
 
   methods: {
     tableClick(row) {
+      this.removeWebGLTile("mapCon1");
+      this.removeWebGLTile("mapCon2");
       let urlQsx = this.newObj.proxypath + row.qsxtif;
       let urlHsx = this.newObj.proxypath + row.hsxtif;
       if (this.nowId != row.id) {
@@ -159,6 +161,16 @@ export default {
         this.nowId = "";
       }
     },
+    removeWebGLTile(name) {
+      console.log(name);
+      const allLayers = window.map[name].getLayers().getArray();
+      allLayers.forEach((layer) => {
+        if (layer instanceof WebGLTile) {
+          window.map[name].removeLayer(layer);
+        }
+      });
+      console.log(window.map[name].getLayers().getArray(), name);
+    },
     addLayer(name, url) {
       const source = new GeoTIFF({
         sources: [