changeset 566:5bffc731ba48 annotations

fix active layer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Sep 2026 18:22:12 +0200
parents 2949bd229f0d
children b596132164b6
files ViewerPlugin/WebApplication/viewer.js
diffstat 1 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ViewerPlugin/WebApplication/viewer.js	Tue Sep 01 18:12:18 2026 +0200
+++ b/ViewerPlugin/WebApplication/viewer.js	Tue Sep 01 18:22:12 2026 +0200
@@ -23,8 +23,6 @@
 
 var app = new Vue({
   el: '#app',
-  computed: {
-  },
 
   data() {
     return {
@@ -111,6 +109,17 @@
     };
   },
 
+  computed: {
+  },
+
+  watch: {
+    activeUserLayerId: function() {
+      if (this.activeDrawTool === 'modify') {
+        this.RefreshModifyFeatureCollection();
+      }
+    }
+  },
+
   mounted: function() {
     this.InitializePanelAnimation();
 
@@ -532,12 +541,7 @@
       this.DeactivateAll();
       if (!wasActive) {
         if (toolName === 'modify') {
-          this.modifyFeatureCollection.clear();
-          this.drawSource.getFeatures().forEach(function(feature) {
-            if (feature.get('layer-id') === app.activeUserLayerId) {
-              app.modifyFeatureCollection.push(feature);
-            }
-          });
+          this.RefreshModifyFeatureCollection();
         }
         this.map.addInteraction(interactions[toolName]);
         if (drawTools.indexOf(toolName) !== -1) {
@@ -551,6 +555,19 @@
       }
     },
 
+    RefreshModifyFeatureCollection: function() {
+      if (this.modifyFeatureCollection !== null &
+          this.drawSource !== null) {
+        var activeLayerId = this.activeUserLayerId;
+        this.modifyFeatureCollection.clear();
+        this.drawSource.getFeatures().forEach(function(feature) {
+          if (feature.get('layer-id') === activeLayerId) {
+            app.modifyFeatureCollection.push(feature);
+          }
+        });
+      }
+    },
+
     DeleteSelectedAnnotation: function() {
       var selected = this.selectAnnotation.getFeatures();
       if (selected.getLength() > 0) {