From a24c227919a82a37344f66ad9de1146fc99c4de9 Mon Sep 17 00:00:00 2001 From: volterra79 Date: Wed, 22 Nov 2023 12:19:59 +0100 Subject: [PATCH] Fix delete part of multipart. Wrong context methods --- .../steps/tasks/deletepartfrommultigeometriestask.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/workflows/steps/tasks/deletepartfrommultigeometriestask.js b/workflows/steps/tasks/deletepartfrommultigeometriestask.js index e0073d1d..20d28f75 100644 --- a/workflows/steps/tasks/deletepartfrommultigeometriestask.js +++ b/workflows/steps/tasks/deletepartfrommultigeometriestask.js @@ -31,10 +31,13 @@ proto.run = function(inputs, context) { source, style: editingLayer.getStyle() }); + map.addLayer(tempLayer); - map.once('postrender', function(){ + map.once('postrender', () => { let found = false; - this.forEachFeatureAtPixel(pixel, _feature => { + //need to call map.forEachFeatureAtPixel and not this.forEachFeatureAtPixel + //beacuse we use arrow function and it referred this to outside context + map.forEachFeatureAtPixel(pixel, _feature => { if (!found) { source.removeFeature(_feature); if (source.getFeatures().length) { @@ -69,7 +72,9 @@ proto.run = function(inputs, context) { hitTolerance: 1 } ); - this.removeLayer(tempLayer); + //need to call map.forEachFeatureAtPixel and not this.forEachFeatureAtPixel + //beacuse we use arrow function and it referred this to outside context + map.removeLayer(tempLayer); tempLayer = null; }); return d.promise()