From c56e506fd34c58209240e97fc29043639fae5d19 Mon Sep 17 00:00:00 2001
From: ChenZeping <chenzeping>
Date: 星期四, 29 四月 2021 15:13:21 +0800
Subject: [PATCH] 统计表,指标,预报警表格弹框公共修改,管线分析功能

---
 src/components/LayerController/service/LayerFactory.js |   56 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index 5aedc79..2ab18e6 100644
--- a/src/components/LayerController/service/LayerFactory.js
+++ b/src/components/LayerController/service/LayerFactory.js
@@ -8,6 +8,7 @@
     this.map = window.map
     this.layers = {}
     this.layersLogic = {}
+    this.minZoomLayers = {}
   }
 
   init (layerConfig) {
@@ -21,10 +22,23 @@
         layers && this.init(config.layers)
         childLayer && this.init(config.childLayer)
 
+        this.initMinZoom(config)
         this.loadLogic(config)
-        this.toggleZoomByConfig(config)
         checked && this.show(config)
       }
+    }
+  }
+
+  initMinZoom (config) {
+    const minZoom = parseInt(config.minZoom)
+    if (minZoom) {
+      var configs = this.minZoomLayers[minZoom]
+      if (configs) {
+        configs[configs.length] = config
+      } else {
+        configs = [config]
+      }
+      this.minZoomLayers[minZoom] = configs
     }
   }
 
@@ -93,33 +107,23 @@
      * @param layerConfig
      */
   initEvent (layerConfig) {
-    this.map.on('zoomend ', (e) => this.toggleZoomByLayer(layerConfig))
+    this.map.on('zoomend ', () => this.toggleByZoom())
   }
 
-  toggleZoomByLayer (layerConfig) {
-    var config = layerConfig
-    if (Array.isArray(layerConfig)) {
-      for (var i = 0, l = layerConfig.length; i < l; i++) {
-        config = layerConfig[i]
-        var layers = config.layers
-        var childLayer = config.childLayer
-        layers && this.toggleZoomByLayer(layers)
-        childLayer && this.toggleZoomByLayer(childLayer)
-        this.toggleZoomByConfig(config)
-      }
-    } else {
-      this.toggleZoomByConfig(layerConfig)
-    }
-  }
-
-  toggleZoomByConfig (config) {
+  toggleByZoom () {
     const zoom = this.map.getZoom()
-    var checked = config.checked
-    if (checked && config.minZoom) {
-      if (zoom > config.minZoom) {
-        this.show(config)
-      } else {
-        this.hide(config)
+    for (var k in this.minZoomLayers) {
+      const configs = this.minZoomLayers[k]
+      for (var j in configs) {
+        const config = configs[j]
+        const checked = config.checked
+        // console.log(zoom)
+        // console.log(k)
+        if (checked && zoom > k) {
+          this.show(config)
+        } else if (checked && zoom < k) {
+          this.hide(config)
+        }
       }
     }
   }
@@ -192,7 +196,7 @@
       this.findLayerById(layer.getLayers(), id)
     } else {
       layer.eachLayer(function (layer) {
-        console.log(layer)
+        // console.log(layer)
       })
     }
   }

--
Gitblit v1.8.0