| | |
| | | |
| | | var checked = config.checked |
| | | checked && this.load(config) |
| | | checked && this.toggleZoomByConfnig(config) |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param layerConfig |
| | | */ |
| | | initEvent (layerConfig) { |
| | | this.map.on('zoomend ', (e) => this.toggleByZoom(layerConfig)) |
| | | this.map.on('zoomend ', (e) => this.toggleZoomByLayer(layerConfig)) |
| | | } |
| | | |
| | | toggleByZoom (layerConfig) { |
| | | const zoom = this.map.getZoom() |
| | | if (layerConfig) { |
| | | toggleZoomByLayer (layerConfig) { |
| | | var config = layerConfig |
| | | if (Array.isArray(layerConfig)) { |
| | | for (var i = 0, l = layerConfig.length; i < l; i++) { |
| | | var config = layerConfig[i] |
| | | config = layerConfig[i] |
| | | var layers = config.layers |
| | | var checked = config.checked |
| | | var childLayer = config.childLayer |
| | | layers && this.toggleByZoom(layers) |
| | | childLayer && this.toggleByZoom(childLayer) |
| | | layers && this.toggleZoomByLayer(layers) |
| | | childLayer && this.toggleZoomByLayer(childLayer) |
| | | this.toggleZoomByConfnig(config) |
| | | } |
| | | } else { |
| | | this.toggleZoomByConfnig(layerConfig) |
| | | } |
| | | } |
| | | |
| | | toggleZoomByConfnig (config) { |
| | | const zoom = this.map.getZoom() |
| | | var checked = config.checked |
| | | if (checked && config.minZoom) { |
| | | if (zoom > config.minZoom) { |
| | | this.show(config) |
| | | } else { |
| | | console.log(config.name) |
| | | this.hide(config) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |