| | |
| | | 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 |
| | | } |
| | | var layer = that.loadGeojson(res.data, item) |
| | | that.layerArray[code] = layer |
| | | } |
| | | } else { |
| | | that.layerArray[code].addTo(that.map) |
| | | var _layer = that.layerArray[code].addTo(that.map) |
| | | that.setZIndex(_layer) |
| | | } |
| | | } |
| | | |
| | |
| | | loadGeojson (res, opt) { |
| | | var that = this |
| | | var icon = opt.icon |
| | | const featureGroup = that.L.featureGroup().addTo(that.map) |
| | | const featureGroup = that.L.featureGroup() |
| | | const featureList = [] |
| | | const geojson = that.L.geoJSON(res.features, { |
| | | style: function (feature) { |
| | |
| | | }) |
| | | }, |
| | | onEachFeature: function (feature, layer) { |
| | | console.log(feature) |
| | | console.log(layer) |
| | | featureList.push(layer) |
| | | layer.addTo(featureGroup) |
| | | } |
| | |
| | | // }).addTo(featureGroup) |
| | | }) |
| | | 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() |
| | | featureGroup.addTo(that.map) |
| | | that.setZIndex(featureGroup) |
| | | return featureGroup |
| | | } |
| | | |
| | | /** |
| | | * 设置index,线在最下面,点在上面 |
| | | * @param layerGroup 图层组 |
| | | */ |
| | | setZIndex (layerGroup) { |
| | | console.log(layerGroup) |
| | | var layers = layerGroup.getLayers() |
| | | if (layers.length > 0) { |
| | | var layer = layers[0] |
| | | if (layer.feature && (layer.feature.geometry.type === 'LineString' || layer.feature.geometry.type === 'MultiLineString')) { |
| | | layerGroup.bringToBack() |
| | | } else { |
| | | layerGroup.bringToFront() |
| | | } |
| | | } |
| | | return geojson |
| | | } |
| | | |
| | | removeLayer (item) { |