From f305077e82b1eb1edc45da2d206e976fdb89f66b Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期二, 30 三月 2021 17:04:55 +0800
Subject: [PATCH] 新的图层控制逻辑
---
src/components/LayerController/service/LayerFactory.js | 27 +++++++++++----------------
1 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index 7626125..e7a585c 100644
--- a/src/components/LayerController/service/LayerFactory.js
+++ b/src/components/LayerController/service/LayerFactory.js
@@ -2,15 +2,12 @@
import WfsLayerService from './WfsLayerService'
import BusiLayerService from './BusiLayerService'
import WmsLayerService from './WmsLayerService'
+
class LayerFactory {
constructor (options) {
this.L = options.L
this.map = window.map
this.layers = {}
- }
-
- createLayerGroup () {
- return this.L.layerGroup().addTo(this.map)
}
init () {
@@ -25,28 +22,26 @@
var wfs = childConfig.wfs
var wms = childConfig.wms
var url = childConfig.url
- // 鍒ゆ柇鏄惁宸茬粡鍔犺浇杩囷紝鍔犺浇杩囧氨 蹇界暐鎺�
- const layer = this.layers[code]
+ // 鍒ゆ柇鏄惁宸茬粡鍔犺浇杩囷紝鍔犺浇杩囧氨 鐩存帴寰楀埌瀵硅薄璋冪敤 鏄剧ず鍑芥暟
+ var layer = this.layers[code]
if (!layer) {
- const newLayer = this.createLayerGroup()
- this.layers[code] = newLayer
+ layer = this.L.featureGroup({}).addTo(this.map)
// 2. 鍒ゆ柇绫诲瀷
if (wfs) {
// 3. 瀹炰緥鍖栧叿浣搒ervice
- // var busiLayerService = new BusiLayerService()
- // busiLayerService.init()
var wfsLayerService = new WfsLayerService(childConfig)
- wfsLayerService.init(newLayer)
+ wfsLayerService.init(layer)
}
if (wms) {
var wmsLayerService = new WmsLayerService(childConfig)
- wmsLayerService.init(newLayer)
+ wmsLayerService.init(layer)
}
// 璇锋眰涓氬姟鏁版嵁鎺ュ彛
if (url) {
var busiLayerService = new BusiLayerService(childConfig)
- busiLayerService.init(newLayer)
+ busiLayerService.init(layer)
}
+ layer ? (this.layers[code] = layer) : console.log('LayerFactory锛歯ewLayer is null锛宲lease check !!!')
} else {
this.show(code)
}
@@ -69,9 +64,9 @@
}
/**
- * 璁剧疆index,绾垮湪鏈�涓嬮潰锛岀偣鍦ㄤ笂闈�
- * @param layerGroup 鍥惧眰缁�
- */
+ * 璁剧疆index,绾垮湪鏈�涓嬮潰锛岀偣鍦ㄤ笂闈�
+ * @param layerGroup 鍥惧眰缁�
+ */
setZIndex (layerGroup) {
var layers = layerGroup.getLayers()
if (layers.length > 0) {
--
Gitblit v1.8.0