[Commits] r978 - apps/opengeo/geoexplorer/trunk/lib

commits at geoext.org commits at geoext.org
Wed Jun 3 22:02:43 CEST 2009


Author: tcoulter
Date: 2009-06-03 22:02:42 +0200 (Wed, 03 Jun 2009)
New Revision: 978

Modified:
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
Less of a dirty hack: Tell each layer where it comes from.

Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-06-03 18:58:00 UTC (rev 977)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-06-03 20:02:42 UTC (rev 978)
@@ -160,7 +160,10 @@
                                 {name: "minScale"},
                                 {name: "maxScale"},
                                 {name: "prefix"},
-                                {name: "background", type: "boolean"}
+                                
+                                // Added for GeoExplorer.
+                                {name: "background", type: "boolean"},
+                                {name: "source_id", type: "string"}
                             ]
                         });
                 var data = request.responseXML || request.responseText;
@@ -180,6 +183,12 @@
                     return;
                 }
                 
+                // MODERATELY LARGE DIRTY HACK!
+                // Tell each layer where it came from.
+                store.each(function(record) {
+                    record.set("source_id", id);
+                }, this);
+                
                 var record = new this.layerSources.recordType({
                     url: url,
                     store: store,
@@ -1235,12 +1244,8 @@
             var layer = layerRecord.get('layer');
             if (layer.displayInLayerSwitcher) {
                 
-                // BIG DIRTY HACK!
-                // There's no direct link between layers and their source.
-                // Let's muddle the url a bit and see if we can come up
-                // with something meaningful.
-                var url = layer.url.replace(/wms.*/, "ows").replace(/:80\//, "/")
-                var index = this.layerSources.find("url", url);
+                // Get the source of this layer.
+                var index = this.layerSources.find("identifier", layerRecord.get("source_id"));
                 var source = this.layerSources.getAt(index);
                 
                 if (source == null) {
@@ -1250,7 +1255,7 @@
                     return;
                 }
 
-                sourcesUsed[source.data.identifier] = url;
+                sourcesUsed[source.data.identifier] = source.get("url");
                 
                 var c = {
                     name: layerRecord.get("name"),



More information about the Commits mailing list