From 1812ce8b286bc5f54d8d0ddd47b9c31cd4388eab Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Mon, 20 Jul 2020 16:08:00 +0100 Subject: [PATCH] update source and fire event only if features added --- src/ol/interaction/DragAndDrop.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ol/interaction/DragAndDrop.js b/src/ol/interaction/DragAndDrop.js index 3736e8c633..b41287e2be 100644 --- a/src/ol/interaction/DragAndDrop.js +++ b/src/ol/interaction/DragAndDrop.js @@ -147,21 +147,21 @@ class DragAndDrop extends Interaction { featureProjection: projection, }); if (features && features.length > 0) { + if (this.source_) { + this.source_.clear(); + this.source_.addFeatures(features); + } + this.dispatchEvent( + new DragAndDropEvent( + DragAndDropEventType.ADD_FEATURES, + file, + features, + projection + ) + ); break; } } - if (this.source_) { - this.source_.clear(); - this.source_.addFeatures(features); - } - this.dispatchEvent( - new DragAndDropEvent( - DragAndDropEventType.ADD_FEATURES, - file, - features, - projection - ) - ); } /**