派生自 wuyushui/SewerAndRainNetwork

zhangshuaibao
2021-03-30 1b09fe890938f123fbcccf235620384b7cd9b721
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. 实例化具体service
            // 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:newLayer is null,please 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) {