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

commits at geoext.org commits at geoext.org
Mon Mar 23 20:08:00 CET 2009


Author: tschaub
Date: 2009-03-23 20:08:00 +0100 (Mon, 23 Mar 2009)
New Revision: 251

Added:
   apps/opengeo/geoexplorer/trunk/debug.html
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/dispatch.js
Log:
Adding basic application code.  Application initializes a layout with a map panel, a layer tree, and a place for a legend.

Added: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html	                        (rev 0)
+++ apps/opengeo/geoexplorer/trunk/debug.html	2009-03-23 19:08:00 UTC (rev 251)
@@ -0,0 +1,26 @@
+<html>
+    <head>
+        <title>GeoExplorer (debug)</title>
+        
+        <!-- Ext resources -->
+        <link rel="stylesheet" type="text/css" href="externals/ext/resources/css/ext-all.css" />
+        <link rel="stylesheet" type="text/css" href="externals/ext/resources/css/xtheme-gray.css" />
+        <script type="text/javascript" src="externals/ext/adapter/ext/ext-base.js"></script>
+        <script type="text/javascript" src="externals/ext/ext-all-debug.js"></script>
+
+        <!-- OpenLayers resources -->
+        <link rel="stylesheet" type="text/css" href="externals/openlayers/theme/default/style.css" />
+        <script type="text/javascript" src="externals/openlayers/lib/OpenLayers.js"></script>
+
+        <!-- GeoExt resources -->
+        <script type="text/javascript" src="externals/geoext/lib/GeoExt.js"></script> 
+
+        <!-- GeoExplorer resources -->
+        <script type="text/javascript" src="lib/GeoExplorer.js"></script> 
+        <script type="text/javascript" src="lib/GeoExplorer/dispatch.js"></script> 
+
+        <script>var app = new GeoExplorer;</script>
+
+    </head>
+    <body></body>
+</html>

Added: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/dispatch.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/dispatch.js	                        (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/dispatch.js	2009-03-23 19:08:00 UTC (rev 251)
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+Ext.namespace("GeoExplorer");
+
+/**
+ * Function: GeoExplorer.dispatch
+ * Allows multiple asynchronous sequences to be called in parallel.  A final
+ *     callback is called when all other sequences report that they are done.
+ * 
+ * Parameters:
+ * functions - {Array(Function)} List of functions to be called.  All
+ *     functions will be called with two arguments - a callback to call when
+ *     the sequence is done and a storage object
+ * complete - {Function} A function that will be called when all other
+ *     functions report that they are done.  The final callback will be
+ *     called with the storage object passed to all other functions.
+ * scope - {Object} Optional object to be set as the scope of all functions
+ *     called.
+ */
+GeoExplorer.dispatch = function(functions, complete, scope) {
+    var requests = functions.length;
+    var responses = 0;
+    var storage = {};
+    function respond() {
+        ++responses;
+        if(responses === requests) {
+            complete.call(scope, storage);
+        }
+    }
+    function trigger(index) {
+        window.setTimeout(function() {
+            functions[index].apply(scope, [respond, storage]);
+        });
+    }
+    for(var i=0; i<requests; ++i) {
+        trigger(i);
+    }
+};

Added: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	                        (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-03-23 19:08:00 UTC (rev 251)
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * Constructor: GeoExplorer
+ * Create a new GeoExplorer application.
+ *
+ * Extends:
+ *  - Ext.util.Observable
+ */
+var GeoExplorer = function() {
+    
+    // add any custom application events
+    this.addEvents(
+        /**
+         * Event: ready
+         * Fires when the entire application is ready.
+         */
+        "ready"
+    );
+    
+    // load the app
+    GeoExplorer.dispatch(
+        [
+            function(done) {
+                Ext.onReady(function() {
+                    this.initLayout();
+                    done();
+                }, this);
+            }
+            // other functions to be executed in parallel can go here
+        ], function() {
+            // executed when all of the above are done
+            this.fireEvent("ready");
+        },
+        this // scope for all above functions
+    );
+    
+};
+
+Ext.extend(GeoExplorer, Ext.util.Observable, {
+    
+    /**
+     * Method: initLayout
+     */
+    initLayout: function() {
+        
+        // keep reference to map handy
+        this.map = new OpenLayers.Map();
+        
+        var mapPanel = new GeoExt.MapPanel({
+            border: true,
+            region: "center",
+            map: this.map,
+            layers: [new OpenLayers.Layer.WMS(
+                "bluemarble",
+                "http://sigma.openplans.org/geoserver/wms?",
+                {layers: 'bluemarble'}
+            )],
+            center: new OpenLayers.LonLat(0, 0),
+            zoom: 2
+        });
+
+        this.layersContainer = new Ext.Panel({
+            autoScroll: true,
+            title: "Layers",
+            anchor: "100%, -200",
+            items: [{
+                xtype: "treepanel",
+                border: false,
+                rootVisible: false,
+                root: new GeoExt.tree.LayerContainer({
+                    text: 'Map Layers',
+                    map: this.map
+                })
+            }]
+        });
+
+        this.legendContainer = new Ext.Panel({
+            title: "Legend",
+            height: 200,
+            items: [{html: ""}]
+        });
+
+        var westPanel = new Ext.Panel({
+            border: true,
+            layout: "anchor",
+            region: "west",
+            width: 250,
+            split: true,
+            collapsible: true,
+            collapseMode: "mini",
+            items: [
+                this.layersContainer, this.legendContainer
+            ]
+        });
+
+        var viewport = new Ext.Viewport({
+            layout: "fit",
+            hideBorders: true,
+            items: {
+                layout: "border",
+                deferredRender: false,
+                items: [mapPanel, westPanel]
+            }
+        });
+
+    }
+    
+});
\ No newline at end of file



More information about the Commits mailing list