[fusion-commits] r1901 - trunk/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Sep 18 14:47:19 EDT 2009


Author: zjames
Date: 2009-09-18 14:47:17 -0400 (Fri, 18 Sep 2009)
New Revision: 1901

Modified:
   trunk/widgets/Redline.js
Log:
fixes 290: multiple redline widgets will now share a single set of layers

Modified: trunk/widgets/Redline.js
===================================================================
--- trunk/widgets/Redline.js	2009-09-18 17:46:29 UTC (rev 1900)
+++ trunk/widgets/Redline.js	2009-09-18 18:47:17 UTC (rev 1901)
@@ -97,10 +97,14 @@
  
         this.styleMap = new OpenLayers.StyleMap(defaultFeatureStyle);
         
-        // create only one default layer
-        this.vectorLayers = new Array();
-        this.vectorLayers[0] = new OpenLayers.Layer.Vector("Digitizing Layer 0", {styleMap: this.styleMap});
-        this.mapWidget.oMapOL.addLayers([this.vectorLayers[0]]);
+        // create one default layer, unless other redline widgets have created it
+        this.vectorLayers = this.mapWidget.oMapOL.getLayersByName('Digitizing Layer 0');
+    
+        if (!this.vectorLayers.length) {
+            this.vectorLayers[0] = new OpenLayers.Layer.Vector("Digitizing Layer 0", {styleMap: this.styleMap});
+            this.vectorLayers[0].redLineLayer = true;
+            this.mapWidget.oMapOL.addLayers([this.vectorLayers[0]]);
+        }
 
         this.createDrawControls();
 
@@ -247,6 +251,7 @@
     newLayer: function(layerName) {
         var i = this.vectorLayers.length;
         this.vectorLayers[i] = new OpenLayers.Layer.Vector(layerName, {styleMap: this.styleMap});
+        this.vectorLayers[i].redLineLayer = true;
         this.mapWidget.oMapOL.addLayer(this.vectorLayers[i]);
     },
     
@@ -260,6 +265,7 @@
             }),
             styleMap: this.styleMap
         });
+        this.vectorLayers[i].redLineLayer = true;
         this.mapWidget.oMapOL.addLayer(this.vectorLayers[i]);
     },
 
@@ -271,6 +277,7 @@
         if (this.vectorLayers.length == 0) {
             this.vectorLayers[0] = new OpenLayers.Layer.Vector("Digitizing Layer 0", {styleMap: this.styleMap});
             this.mapWidget.oMapOL.addLayers([this.vectorLayers[0]]);
+            this.vectorLayers[0].redLineLayer = true;
         }
         this.activateLayer(0);
     }
@@ -399,6 +406,15 @@
         var select = this.taskPaneWin.document.getElementById('RedlineWidgetLayerList');
         var selectedIndex = select.selectedIndex;
         select.length = 0;
+        var olMap = this.widget.mapWidget.oMapOL;
+        var numLayers = olMap.getNumLayers();
+        this.widget.vectorLayers = [];
+        for (var i=0; i < numLayers; i++) {
+            if (olMap.layers[i].redLineLayer) {
+                this.widget.vectorLayers.push(olMap.layers[i]);
+            }
+        };
+        
         for ( var i = 0; i < this.widget.vectorLayers.length;i++)
         {
             var opt = document.createElement('option');



More information about the fusion-commits mailing list