From 270b06c2faed5f2aa564c4a3b1246a5891188bc7 Mon Sep 17 00:00:00 2001 From: wangqi <magical1908@outlook.com> Date: 星期二, 13 四月 2021 16:01:14 +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