diff --git a/src/views/spongePerformance/waterUtilizationRate/odorousWaterBodies/todoDon.vue b/src/views/spongePerformance/waterUtilizationRate/odorousWaterBodies/todoDon.vue index 743ff4c..f1c9613 100644 --- a/src/views/spongePerformance/waterUtilizationRate/odorousWaterBodies/todoDon.vue +++ b/src/views/spongePerformance/waterUtilizationRate/odorousWaterBodies/todoDon.vue @@ -174,7 +174,7 @@ let black_odor = [], black_odor_label = []; res.data.forEach(data => { - data.fillcolor = '#d9001b'; + data.fillcolor = data.isExamine == 1 ? '#70b603' : '#d9001b'; let waterLine = turf.feature(Terraformer.WKT.parse(data.geometrys), data); let waterLabel = turf.center(waterLine, { properties: data, @@ -184,12 +184,10 @@ }); let waterLineGeojson = turf.featureCollection(black_odor); let waterLabelGeojson = turf.featureCollection(black_odor_label); - console.log('blackWaterGeojson---', waterLineGeojson); - console.log('waterLabelGeojson---', waterLabelGeojson); + if (!newfiberMapbox.map.getLayer('waterLine')) { + newfiberMapbox.map.addSource('waterLine', { type: 'geojson', data: waterLineGeojson }); + newfiberMapbox.map.addSource('waterLabel', { type: 'geojson', data: waterLabelGeojson }); - !newfiberMapbox.map.getSource('waterLine') && newfiberMapbox.map.addSource('waterLine', { type: 'geojson', data: waterLineGeojson }); - !newfiberMapbox.map.getSource('waterLabel') && newfiberMapbox.map.addSource('waterLabel', { type: 'geojson', data: waterLabelGeojson }); - !newfiberMapbox.map.getLayer('waterLine') && newfiberMapbox.map.addLayer({ id: 'waterLine', type: 'line', @@ -199,7 +197,7 @@ 'line-width': 5, }, }); - !newfiberMapbox.map.getLayer('waterLabel') && + newfiberMapbox.map.addLayer({ id: 'waterLabel', type: 'symbol', @@ -217,6 +215,10 @@ 'text-halo-width': 1, }, }); + } else { + newfiberMapbox.map.getSource('waterLine').setData(waterLineGeojson); + newfiberMapbox.map.getSource('waterLabel').setData(waterLabelGeojson); + } //newfiberMapbox.map.moveLayer('waterLine', 'odorousWaterBodies'); }