From 7af28eaca09c2aa1f9a678df081abb378e22ee16 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期三, 10 三月 2021 10:12:17 +0800
Subject: [PATCH] 菜单组件联动
---
src/components/helpers/ServiceLayerHelper.js | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js
index a38ef6c..567be72 100644
--- a/src/components/helpers/ServiceLayerHelper.js
+++ b/src/components/helpers/ServiceLayerHelper.js
@@ -116,18 +116,19 @@
* @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)
+ var layer = that.loadGeojson(res.data, item)
that.layerArray[code] = layer
- })
+ }
} else {
that.layerArray[code].addTo(that.map)
}
@@ -140,6 +141,8 @@
loadGeojson (res, opt) {
var that = this
var icon = opt.icon
+ const featureGroup = that.L.featureGroup()
+ const featureList = []
const geojson = that.L.geoJSON(res.features, {
style: function (feature) {
return {
@@ -148,9 +151,9 @@
fillColor: styles.defaultLineStyle.fillColor,
color: styles.defaultLineStyle.color,
fillOpacity: styles.defaultLineStyle.fillOpacity,
- opacity: styles.defaultLineStyle.opacity
- // dashArray: styles.defaultLineStyle.dashArray,
- // dashSpeed: styles.defaultLineStyle.dashSpeed
+ opacity: styles.defaultLineStyle.opacity,
+ dashArray: styles.defaultLineStyle.dashArray,
+ dashSpeed: styles.defaultLineStyle.dashSpeed
}
},
pointToLayer: function (geoJsonPoint, latlng) {
@@ -162,6 +165,12 @@
size: styles.defaultLineStyle.size
}
})
+ },
+ onEachFeature: function (feature, layer) {
+ console.log(feature)
+ console.log(layer)
+ featureList.push(layer)
+ layer.addTo(featureGroup)
}
}).bindPopup(function (layer) {
that.popupComp.setDatas(layer)
@@ -215,14 +224,17 @@
}
})
}
- }).addTo(that.map)
+ // }).addTo(that.map)
+ // }).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()
}
- return geojson
+ featureGroup.addTo(that.map)
+ return featureGroup
}
removeLayer (item) {
--
Gitblit v1.8.0