[Commits] r254 - in apps/opengeo/geoexplorer/trunk: . lib

commits at geoext.org commits at geoext.org
Mon Mar 23 23:14:06 CET 2009


Author: tschaub
Date: 2009-03-23 23:14:05 +0100 (Mon, 23 Mar 2009)
New Revision: 254

Modified:
   apps/opengeo/geoexplorer/trunk/debug.html
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
use a layer store so we can store additional layer metadata on layer records

Modified: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html	2009-03-23 21:35:14 UTC (rev 253)
+++ apps/opengeo/geoexplorer/trunk/debug.html	2009-03-23 22:14:05 UTC (rev 254)
@@ -21,14 +21,15 @@
 
         <script>
             var app = new GeoExplorer({
-                ows: "http://sigma.openplans.org/geoserver/ows",
+                ows: "/geoserver/ows",
                 map: {
                     layers: [{
-                        name: "bluemarble",
-                        title: "Global Imagery"
+                        name: "topp:states",
+                        title: "States",
+                        queryable: true
                     }],
-                    center: [0, 0],
-                    zoom: 2
+                    center: [-96.7, 37.6],
+                    zoom: 4
                 }
             });
         </script>

Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-03-23 21:35:14 UTC (rev 253)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-03-23 22:14:05 UTC (rev 254)
@@ -51,6 +51,13 @@
     map: null,
     
     /**
+     * Property: layers
+     * {GeoExt.data.LayerStore} A store containing a record for each layer
+     *     on the map.
+     */
+    layers: null,
+    
+    /**
      * Property: load
      * Called at the end of construction.  This initiates the sequence that
      *     prepares the application for use.
@@ -82,13 +89,18 @@
         // create the map
         this.initMap();
         
+        // create the layers store
+        this.initLayers();
+        
         // place map in panel
         var mapConfig = this.initialConfig.map || {};
         var mapPanel = new GeoExt.MapPanel({
             border: true,
             region: "center",
             map: this.map,
+            // TODO: update the OpenLayers.Map constructor to accept an initial center
             center: mapConfig.center && new OpenLayers.LonLat(mapConfig.center[0], mapConfig.center[1]),
+            // TODO: update the OpenLayers.Map constructor to accept an initial zoom
             zoom: mapConfig.zoom
         });
 
@@ -143,37 +155,50 @@
      * Construct the map and reference it on the applicaiton as <map>.
      */
     initMap: function() {
+        // TODO: check this.initialConfig.map for any map options
+        this.map = new OpenLayers.Map();
+    },
+    
+    /**
+     * Method: initLayers
+     * Construct the layer store to be used with the map (referenced as <layers>).
+     */
+    initLayers: function() {
         var mapConfig = this.initialConfig.map;
         var ows = this.initialConfig.ows;
+        
+        this.layers = new GeoExt.data.LayerStore({
+            map: this.map
+        });
+        
+        // create a record for the dummy layer that acts as the single baselayer
+        var records = [
+            new GeoExt.data.LayerRecord(
+                new OpenLayers.Layer(null, {
+                    isBaseLayer: true,
+                    displayInLayerSwitcher: false
+                })
+            )
+        ];
 
-        var map = new OpenLayers.Map();
-        // create a dummy layer that acts as the single "base" layer
-        map.addLayer(
-            new OpenLayers.Layer(null, {
-                isBaseLayer: true,
-                displayInLayerSwitcher: false
-            })
-        );
-
         if(mapConfig) {
             if(mapConfig.layers) {
-                var layer, layers = [];
+                var layer;
                 for(var i=0, len=mapConfig.layers.length; i<len; ++i) {
                     layer = mapConfig.layers[i];
-                    layers.push(
+                    records.push(new GeoExt.data.LayerRecord(
                         new OpenLayers.Layer.WMS(
                             layer.title || layer.name,
                             ows,
                             {layers: layer.name},
                             {isBaseLayer: false}
-                        )
-                    );
+                        ),
+                        layer // pass all additional layer config properties
+                    ));
                 }
             }
-            map.addLayers(layers);
         }
-        
-        this.map = map;
+        this.layers.add(records);
     }
     
 });
\ No newline at end of file



More information about the Commits mailing list