派生自 wuyushui/SewerAndRainNetwork

YANGDL
2021-03-08 47af46140c4ca30488030e93d20a1965b2c848a2
src/components/helpers/ServiceLayerHelper.js
@@ -16,13 +16,27 @@
    this.tileLayersTileArray = [] // 初始的Tile集
    this.tileLayersWMSArray = [] // 初始的WMS集
    this.layerArray = {} // key为配置的code,加载的图层对象,
    this.layerConfig = {}
    this.regex = /\{(.+?)\}/g // 匹配{}
    this.popupComp = null
  }
  getTileLayer (code) {
    return this.loadedLayersMap.get(code)
  }
  getByLayerId (layerId) {
    for (var k in this.layerArray) {
      var layer = this.layerArray[k]
      var geojson = layer.toGeoJSON()
      var features = geojson.features
      for (var j = 0; j < features.length; j++) {
        var feature = features[j]
        if (feature.id === layerId) {
          return layer
        }
      }
    }
    return null
  }
  initDisplayZoom (layerConfig) {
@@ -114,6 +128,8 @@
        var layer = that.loadGeojson(res, item)
        that.layerArray[code] = layer
      })
    } else {
      that.layerArray[code].addTo(that.map)
    }
  }
@@ -124,7 +140,6 @@
  loadGeojson (res, opt) {
    var that = this
    var icon = opt.icon
    const featureGroup = that.L.featureGroup().addTo(that.map)
    const geojson = that.L.geoJSON(res.features, {
      style: function (feature) {
        return {
@@ -200,14 +215,14 @@
            }
          })
        }
      }).addTo(featureGroup)
      }).addTo(that.map)
    store.commit('addSewersDatas', geojson)
    if (Object.prototype.hasOwnProperty.call(res, 'features') && res.features.length > 0 && (res.features[0].geometry.type === 'LineString' || res.features[0].geometry.type === 'MultiLineString')) {
      geojson.bringToBack()
    } else {
      geojson.bringToFront()
    }
    return featureGroup
    return geojson
  }
  removeLayer (item) {