[fusion-commits] r1990 - trunk/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Nov 24 22:28:03 EST 2009


Author: christinebao
Date: 2009-11-24 22:28:02 -0500 (Tue, 24 Nov 2009)
New Revision: 1990

Modified:
   trunk/widgets/Redline.js
Log:
Fix ticket http://trac.osgeo.org/fusion/ticket/320
Two Layers with the same name could be created in the Redline Panel

Modified: trunk/widgets/Redline.js
===================================================================
--- trunk/widgets/Redline.js	2009-11-24 20:55:16 UTC (rev 1989)
+++ trunk/widgets/Redline.js	2009-11-25 03:28:02 UTC (rev 1990)
@@ -280,6 +280,23 @@
             this.vectorLayers[0].redLineLayer = true;
         }
         this.activateLayer(0);
+    },
+
+    getUniqueLayerName: function() {
+        var offset = this.vectorLayers.length;
+        var exist = true;
+        while (exist) {
+            exist = false;
+            var i = 0;
+            while (!exist && i < this.vectorLayers.length) {
+                if (("Digitizing layer " + offset) == this.vectorLayers[i].name)
+                    exist = true;
+                i++;
+            }
+            if (exist)
+                offset++;
+        }
+        return "Digitizing layer " + offset;
     }
 });
 
@@ -363,8 +380,8 @@
         doc.getElementById("RedlineWidgetRenameFeatureButton").onclick = OpenLayers.Function.bind(this.renameFeature, this);
     },
 
-    newLayer: function() {
-        var name = prompt("Layer name:", "Digitizing layer "+this.widget.vectorLayers.length);
+    newLayer: function() {
+        var name = prompt("Layer name:", this.widget.getUniqueLayerName());
         if (name!=null && name!="") {
             this.widget.newLayer(name);
             this.updateLayerList();



More information about the fusion-commits mailing list