派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-02-26 1883c95da4b79da03365e8e0eea6b917e6cb4f10
src/components/helpers/ServiceLayerHelper.js
@@ -5,6 +5,7 @@
import AjaxUtils from '@/utils/AjaxUtils'
import store from '@/store'
var myRenderer = window.L.canvas()
class ServiceLayerHelper {
  constructor (options) {
    this.map = options.map
@@ -69,16 +70,16 @@
    }
  }
  loadGeojsonLayer (url, layer) {
  loadGeojsonLayer (url, item) {
    var matches = this.regex.exec(url)
    var matchValue = layer[matches[1]]
    var code = layer.code
    var matchValue = item[matches[1]]
    var code = item.code
    var newUrl = url.replace(this.regex, matchValue)
    var that = this
    if (!that.geojsonArray[code]) {
      AjaxUtils.GetDataAsynByUrl(newUrl, {}, function (res) {
        store.commit('setMapObj', res)
        var layer = that.loadGeojson(res)
        store.commit('setSewersDatas', res)
        var layer = that.loadGeojson(res, item)
        that.geojsonArray[code] = layer
      })
    }
@@ -88,12 +89,10 @@
     * 加载点数据
     * @param res
     */
  loadGeojson (res) {
  loadGeojson (res, layer) {
    var that = this
    const featureGroup = that.L.featureGroup([], {
      attribution: { id: '123' }
    }).addTo(that.map)
    that.L.geoJSON(res.features, {
    var icon = layer.icon
    return that.L.geoJSON(res.features, {
      style: function (feature) {
        return {
          fill: true,
@@ -111,16 +110,16 @@
          {
            radius: 20,
            img: {
              url: 'assets/images/map/marker-icon.png',
              // url: 'assets/images/map/marker-icon.png',
              url: '/assets/images/map/' + icon,
              size: [20, 20]
            }
          })
      }
      },
      renderer: myRenderer
    }).bindPopup(function (layer) {
      // return layer.feature.properties.linenumber
    }).addTo(featureGroup)
    featureGroup.bringToBack()
    return featureGroup
      return layer.feature.properties.linenumber
    }).addTo(that.map)
  }
  removeLayer (item) {