From ea446a1a9cdaf333a062ea471a3bde02b6eda655 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期二, 13 四月 2021 14:08:39 +0800
Subject: [PATCH] 根据不同级别显示隐藏图层
---
src/components/LayerController/service/LayerFactory.js | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index b617ae5..65f89e6 100644
--- a/src/components/LayerController/service/LayerFactory.js
+++ b/src/components/LayerController/service/LayerFactory.js
@@ -25,6 +25,36 @@
}
}
+ /**
+ * 鎺у埗鏄剧ず鐨勭骇鍒�
+ * @param layerConfig
+ */
+ initEvent (layerConfig) {
+ this.map.on('zoomend ', (e) => this.toggleByZoom(layerConfig))
+ }
+
+ toggleByZoom (layerConfig) {
+ const zoom = this.map.getZoom()
+ if (layerConfig) {
+ for (var i = 0, l = layerConfig.length; i < l; i++) {
+ var config = layerConfig[i]
+ var layers = config.layers
+ var checked = config.checked
+ var childLayer = config.childLayer
+ layers && this.toggleByZoom(layers)
+ childLayer && this.toggleByZoom(childLayer)
+ if (checked && config.minZoom) {
+ if (zoom > config.minZoom) {
+ this.show(config)
+ } else {
+ console.log(config.name)
+ this.hide(config)
+ }
+ }
+ }
+ }
+ }
+
load (config) {
var code = config.code
var wfs = config.wfs
@@ -91,9 +121,9 @@
this.setZIndex(layer.getLayers())
} else {
if (layer.feature && (layer.feature.geometry.type === 'LineString' || layer.feature.geometry.type === 'MultiLineString')) {
- layer.bringToBack()
+ layer.bringToBack && layer.bringToBack()
} else {
- layer.bringToFront()
+ layer.bringToFront && layer.bringToFront()
}
}
}
--
Gitblit v1.8.0