From 176aac34d8841cf5fd9a6032ee9988adf9a6233d Mon Sep 17 00:00:00 2001
From: wangqi <magical1908@outlook.com>
Date: 星期三, 14 四月 2021 12:58:17 +0800
Subject: [PATCH] table数据
---
src/components/LayerController/service/LayerFactory.js | 60 +++++++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index 65f89e6..593b5fd 100644
--- a/src/components/LayerController/service/LayerFactory.js
+++ b/src/components/LayerController/service/LayerFactory.js
@@ -12,7 +12,7 @@
init (layerConfig) {
// 1. 閬嶅巻layer config
if (layerConfig) {
- for (var i = 0, l = layerConfig.length; i < l; i++) {
+ for (var i = 0; i < layerConfig.length; i++) {
var config = layerConfig[i]
var layers = config.layers
var childLayer = config.childLayer
@@ -21,6 +21,7 @@
var checked = config.checked
checked && this.load(config)
+ checked && this.toggleZoomByConfnig(config)
}
}
}
@@ -30,27 +31,33 @@
* @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)
- if (checked && config.minZoom) {
- if (zoom > config.minZoom) {
- this.show(config)
- } else {
- console.log(config.name)
- this.hide(config)
- }
- }
+ 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 {
+ this.hide(config)
}
}
}
@@ -105,6 +112,25 @@
}
+ flyByLayerId (layerId, bound) {
+ for (var k in this.layers) {
+ var layerGroup = this.layers[k]
+ var layers = layerGroup.getLayers()
+ if (layers) {
+ for (var m = 0; m < layers.length; m++) {
+ var layer = layers[m]
+ console.log(layer.toGeoJSON())
+ /* var feature = layer.feature
+ if (feature.id === layerId) {
+ this.map.flyToBounds(bound)
+ return layer
+ } */
+ }
+ }
+ }
+ return null
+ }
+
/**
* todo 杩欓噷鏃犳晥锛岃矊浼兼槸鍥犱负geojson鍔犺浇鍒板湴鍥句篃鏄釜layergroup
*
--
Gitblit v1.8.0