[Commits] r2333 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data
commits at geoext.org
commits at geoext.org
Fri Sep 10 16:59:30 CEST 2010
Author: bartvde
Date: 2010-09-10 16:59:30 +0200 (Fri, 10 Sep 2010)
New Revision: 2333
Modified:
core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js
core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
Log:
WMS capabilities reader should take layerParams as well, r=pgiraud (closes #315)
Modified: core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js 2010-09-10 14:25:34 UTC (rev 2332)
+++ core/trunk/geoext/lib/GeoExt/data/WMSCapabilitiesReader.js 2010-09-10 14:59:30 UTC (rev 2333)
@@ -20,9 +20,11 @@
/** api: constructor
* .. class:: WMSCapabilitiesReader(meta, recordType)
*
- * :param meta: ``Object`` Reader configuration from which
+ * :param meta: ``Object`` Reader configuration from which:
* ``layerOptions`` is an optional object passed as default options
* to the ``OpenLayers.Layer.WMS`` constructor.
+ * ``layerParams`` is an optional set of parameters to pass into the
+ * ``OpenLayers.Layer.WMS`` constructor.
* :param recordType: ``Array | Ext.data.Record`` An array of field
* configuration objects or a record object. Default is
* :class:`GeoExt.data.LayerRecord` with the following fields:
@@ -174,7 +176,7 @@
if(url && layers) {
var fields = this.recordType.prototype.fields;
- var layer, values, options, field, v;
+ var layer, values, options, params, field, v;
for(var i=0, lenI=layers.length; i<lenI; i++){
layer = layers[i];
@@ -197,14 +199,18 @@
if(this.meta.layerOptions) {
Ext.apply(options, this.meta.layerOptions);
}
- values.layer = new OpenLayers.Layer.WMS(
- layer.title || layer.name, url, {
+ params = {
layers: layer.name,
exceptions: exceptions,
format: this.imageFormat(layer),
transparent: this.imageTransparent(layer),
version: version
- }, options
+ };
+ if (this.meta.layerParams) {
+ Ext.apply(params, this.meta.layerParams);
+ }
+ values.layer = new OpenLayers.Layer.WMS(
+ layer.title || layer.name, url, params, options
);
records.push(new this.recordType(values, values.layer.id));
}
Modified: core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html 2010-09-10 14:25:34 UTC (rev 2332)
+++ core/trunk/geoext/tests/lib/GeoExt/data/WMSCapabilitiesReader.html 2010-09-10 14:59:30 UTC (rev 2333)
@@ -32,7 +32,7 @@
'field values set from configuration are correct');
}
function test_read(t) {
- t.plan(39);
+ t.plan(40);
// test a reader with the only two default LayerRecord fields
var reader = new GeoExt.data.WMSCapabilitiesReader({}, []);
@@ -52,6 +52,9 @@
var reader = new GeoExt.data.WMSCapabilitiesReader({
layerOptions: {
singleTile: true
+ },
+ layerParams: {
+ foo: 'TRUE'
}
});
var records = reader.read({responseXML: doc});
@@ -124,6 +127,7 @@
t.eq(typeof(layer.minScale), "number","[2] layer minScale has been set");
t.eq(typeof(layer.maxScale), "number","[2] layer maxScale has been set");
t.eq(layer.singleTile, true, "[2] layer field has correct singleTile attribute (from WMSCapabilitiesReader constructor)");
+ t.eq(layer.params.FOO, "TRUE", "[2] layer field has correct custom parameter");
// 3 tests -- attribution markup
record = records.records[2];
More information about the Commits
mailing list