From 704714d2bbb1cf97cb16d452332c4334bc78a24c Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期二, 20 四月 2021 18:43:24 +0800
Subject: [PATCH] 加排口, 比例尺显示隐藏有BUG,暂时注释
---
src/components/LayerController/service/LayerFactory.js | 41 ++++++++++++++++++-----------------------
1 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index 5aedc79..9387933 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,17 @@
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) {
+ this.minZoomLayers[minZoom] = config
}
}
@@ -93,32 +101,19 @@
* @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) {
+ for (var k in this.minZoomLayers) {
+ const config = this.minZoomLayers[k]
+ const checked = config.checked
+ console.log(zoom)
+ console.log(k)
+ if (checked && zoom > k) {
this.show(config)
- } else {
+ } else if (checked && zoom < k) {
this.hide(config)
}
}
--
Gitblit v1.8.0