[Commits] r1154 - in sandbox/camptocamp/geobretagne: lib/GeoExt/data tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Wed Jun 24 16:17:15 CEST 2009


Author: fredj
Date: 2009-06-24 16:17:15 +0200 (Wed, 24 Jun 2009)
New Revision: 1154

Modified:
   sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js
   sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerStore.html
Log:
fix 'layers set in reverse order' (see #106)

Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js	2009-06-24 11:28:07 UTC (rev 1153)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js	2009-06-24 14:17:15 UTC (rev 1154)
@@ -135,10 +135,9 @@
         var layers = map.layers.slice(0);
 
         if(initDir & GeoExt.data.LayerStore.STORE_TO_MAP) {
-            var records = this.getRange();
-            for(var i=records.length - 1; i>=0; i--) {
-                this.map.addLayer(records[i].get("layer"));
-            }
+            this.each(function(record) {
+                this.map.addLayer(record.get("layer"));
+            }, this);
         }
         if(initDir & GeoExt.data.LayerStore.MAP_TO_STORE) {
             this.loadData(layers, true);

Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerStore.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerStore.html	2009-06-24 11:28:07 UTC (rev 1153)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/LayerStore.html	2009-06-24 14:17:15 UTC (rev 1154)
@@ -84,6 +84,35 @@
             t.eq(mapPanel.layers.getCount(),1,"Adding layers to MapPanel's LayerStore does not create duplicate layers"); 
         }
 
+        function test_store_to_map(t) {
+
+            t.plan(8);
+            
+            var map = new OpenLayers.Map("mappanel");
+            var layers = [new OpenLayers.Layer.Vector("a"),
+                          new OpenLayers.Layer.Vector("b"),
+                          new OpenLayers.Layer.Vector("c")];
+
+            var store = new GeoExt.data.LayerStore({
+                map: map,
+                layers: layers
+            });
+
+            t.eq(store.getCount(), 3, "three layers in store");
+            t.eq(map.layers.length, 3, "three layers on map");
+
+            t.eq(store.getAt(0).get("layer").name, "a", "first layer correct in store");
+            t.eq(map.layers[0].name, "a", "first layer correct on map");
+
+            t.eq(store.getAt(1).get("layer").name, "b", "second layer correct in store");
+            t.eq(map.layers[1].name, "b", "second layer correct on map");
+
+            t.eq(store.getAt(2).get("layer").name, "c", "third layer correct in store");
+            t.eq(map.layers[2].name, "c", "third layer correct on map");
+
+            map.destroy();
+        }
+
         function test_load_clear(t) {
             t.plan(2);
             



More information about the Commits mailing list