diff --git a/src/views/sponeScreen/waterFlood/floodWZ.vue b/src/views/sponeScreen/waterFlood/floodWZ.vue index be6908d..24e0206 100644 --- a/src/views/sponeScreen/waterFlood/floodWZ.vue +++ b/src/views/sponeScreen/waterFlood/floodWZ.vue @@ -95,16 +95,22 @@ if (res && res.code == 200) { let data = res.data; let materialFeatures = []; + let materialPolygonFeatures = []; data.forEach(element => { let feature = turf.point([Number(element.lon), Number(element.lat)], element); feature.properties.name = element.address; element.materialName = element.address; element.lonLat = element.lon + ',' + element.lat; materialFeatures.push(feature); + if (element.geometry) { + materialPolygonFeatures.push(turf.feature(Terraformer.WKT.parse(element.geometry), { fillcolor: 'rgba(25, 101, 141,0.2)' })); + } }); let materialGeojson = turf.featureCollection(materialFeatures); console.log('materialGeojson---', materialGeojson); + let materialPolygonGeojson = turf.featureCollection(materialPolygonFeatures); newfiberMapBoxVectorLayer.addGeojsonSymbol('materialFeatures', materialGeojson, yuanTous); //地图添加防汛物资 + newfiberMapBoxVectorLayer.addGeojsonPolygon('materialPolygonFeatures', materialPolygonGeojson); initeLayerList.forEach(item => { item.show = isMaterialShow.value; }); @@ -117,6 +123,7 @@ bus.emit('setIniteLayer', initeLayerList); newfiberMapBoxVectorLayer.removeByIds(['materialFeatures']); newfiberMapbox.map.removeImage('materialFeatures'); + newfiberMapBoxVectorLayer.removeByIds(['materialPolygonFeatures']); } }; onMounted(() => { diff --git a/src/views/sponeScreen/waterFlood/floodWZ.vue b/src/views/sponeScreen/waterFlood/floodWZ.vue index be6908d..24e0206 100644 --- a/src/views/sponeScreen/waterFlood/floodWZ.vue +++ b/src/views/sponeScreen/waterFlood/floodWZ.vue @@ -95,16 +95,22 @@ if (res && res.code == 200) { let data = res.data; let materialFeatures = []; + let materialPolygonFeatures = []; data.forEach(element => { let feature = turf.point([Number(element.lon), Number(element.lat)], element); feature.properties.name = element.address; element.materialName = element.address; element.lonLat = element.lon + ',' + element.lat; materialFeatures.push(feature); + if (element.geometry) { + materialPolygonFeatures.push(turf.feature(Terraformer.WKT.parse(element.geometry), { fillcolor: 'rgba(25, 101, 141,0.2)' })); + } }); let materialGeojson = turf.featureCollection(materialFeatures); console.log('materialGeojson---', materialGeojson); + let materialPolygonGeojson = turf.featureCollection(materialPolygonFeatures); newfiberMapBoxVectorLayer.addGeojsonSymbol('materialFeatures', materialGeojson, yuanTous); //地图添加防汛物资 + newfiberMapBoxVectorLayer.addGeojsonPolygon('materialPolygonFeatures', materialPolygonGeojson); initeLayerList.forEach(item => { item.show = isMaterialShow.value; }); @@ -117,6 +123,7 @@ bus.emit('setIniteLayer', initeLayerList); newfiberMapBoxVectorLayer.removeByIds(['materialFeatures']); newfiberMapbox.map.removeImage('materialFeatures'); + newfiberMapBoxVectorLayer.removeByIds(['materialPolygonFeatures']); } }; onMounted(() => { diff --git a/src/views/sponeScreen/waterFlood/index.vue b/src/views/sponeScreen/waterFlood/index.vue index 3145b2b..255e8c8 100644 --- a/src/views/sponeScreen/waterFlood/index.vue +++ b/src/views/sponeScreen/waterFlood/index.vue @@ -186,9 +186,10 @@ bus.off('pipeMonitorBus'); if (!newfiberMapbox) return; newfiberMapbox.removeLayer(newfiberMapbox.getLayerByName('waterFlow')); - newfiberMapBoxVectorLayer.removeByIds(['materialFeatures']); if (newfiberMapbox.map.hasImage('materialFeatures')) { newfiberMapbox.map.removeImage('materialFeatures'); + newfiberMapBoxVectorLayer.removeByIds(['materialPolygonFeatures']); + newfiberMapBoxVectorLayer.removeByIds(['materialFeatures']); } bus.emit('setIniteLayer', [ {