Ver código fonte

图层子layer显隐

maxiaoxiao 9 meses atrás
pai
commit
a14acc5a79

+ 16 - 4
src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

@@ -44,6 +44,7 @@ import * as wellknown from "wellknown";
 import * as turf from "@turf/turf";
 
 let BoxCommonVector_entity = null;
+let layersObj = {}
 export default {
     data() {
         return {
@@ -53,7 +54,8 @@ export default {
             active_dableData: null,
             tableData: null,
             layersData: {},
-            scrollTop_index: null
+            scrollTop_index: null,
+            tempdataLayerId: null,
         };
     },
     methods: {
@@ -77,14 +79,19 @@ export default {
               this.layersData.layerName = layers[0].name
         },
         async setLayerStatus(item) {
-            if(this.layersData.layerName){
+            this.tempdataLayerId = item.did
+            if(layersObj[item.did]){
+                layersObj[item.did].show = true
+            }else if(this.layersData.layerName){
                 var params_gh = {
                     layerName: this.layersData.layerName,
                     isVisible: true,
                     displayFilter: `xmmc = '${item['项目名称']}'`
                 }
-                console.log(params_gh,'params_gh')
-                tdsy.superProvider.setLayerStatusParameters([params_gh],150000,item.id)
+                tdsy.superProvider.setLayerStatusParameters([params_gh])
+                tdsy.layer.show = false
+                let layer = viewer.imageryLayers.addImageryProvider(tdsy.superProvider);
+                layersObj[item.did] = layer
             }else{
                 Message.error('缺少图层名称,设置失败')
             }
@@ -481,6 +488,11 @@ export default {
             if (this.cockpit_vector.mapType) this.draw_vector_server(this.cockpit_vector.mapType)
             else this.draw_vector_tdgy_gy_jd(newVal);
         },
+        tempdataLayerId(newVal, oldVal) {
+        if (oldVal) {
+            layersObj[oldVal].show = false
+        }
+      },
         computed_vectorData(newVal, oldVal) {
             newVal.forEach((res) => {
                 if (res.name == 'index') {