派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-03-07 4bf99ece0279cedde3b1f6c888b64265534640c0
修改图层控制
2个文件已修改
22 ■■■■ 已修改文件
src/components/helpers/ServiceLayerHelper.js 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/panel/topicSearch/SewersSearch.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/helpers/ServiceLayerHelper.js
@@ -25,7 +25,18 @@
  }
  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) {
@@ -129,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 {
@@ -205,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) {
src/components/panel/topicSearch/SewersSearch.vue
@@ -173,6 +173,7 @@
      wfsHelper.addLike(this.form.query.key, this.form.keyword)
      // const _this = this
      AjaxUtils.GetDataAsynByUrl(wfsHelper.getUrl(), {}, (res) => {
        console.log(res)
        this.list = res.features
      })
    },
@@ -180,6 +181,9 @@
      console.log(val)
      const bound = this.L.geoJSON([val], {}).getBounds()
      console.log(bound)
      var layer = window.serviceLayerHelper.getByLayerId(val.id)
      console.log(layer)
      layer && layer.openPopup()
      this.$store.state.map.map.flyToBounds(bound)
    }
  }