| | |
| | | * @param url |
| | | * @param item |
| | | */ |
| | | loadGeojsonLayer (url, item) { |
| | | async loadGeojsonLayer (url, item) { |
| | | var matches = this.regex.exec(url) |
| | | var matchValue = item[matches[1]] |
| | | var code = item.code |
| | | var newUrl = url.replace(this.regex, matchValue) |
| | | var that = this |
| | | if (!that.layerArray[code]) { |
| | | AjaxUtils.GetDataAsynByUrl(newUrl, {}, function (res) { |
| | | store.commit('addSewersDatas', res) |
| | | var layer = that.loadGeojson(res, item) |
| | | const res = await AjaxUtils.GetDataAsynByUrl(newUrl, {}) |
| | | if (res.data instanceof Object && Object.prototype.hasOwnProperty.call(res.data, 'features')) { |
| | | store.commit('addSewersDatas', res.data) |
| | | if (newUrl.indexOf('管网') !== -1 || newUrl.indexOf('四通') !== -1) { |
| | | var layer = that.loadGeojson(res.data, item) |
| | | that.layerArray[code] = layer |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | that.layerArray[code].addTo(that.map) |
| | | } |
| | |
| | | loadGeojson (res, opt) { |
| | | var that = this |
| | | var icon = opt.icon |
| | | const layergroup = that.L.featureGroup().addTo(that.map) |
| | | const geojson = that.L.geoJSON(res.features, { |
| | | style: function (feature) { |
| | | return { |
| | |
| | | } |
| | | }) |
| | | } |
| | | }).addTo(that.map) |
| | | // }).addTo(that.map) |
| | | }).addTo(layergroup) |
| | | 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() |