[Commits] r2401 - in core/trunk/geoext: lib/GeoExt/widgets tests/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Fri Sep 24 07:00:08 CEST 2010


Author: bartvde
Date: 2010-09-24 07:00:08 +0200 (Fri, 24 Sep 2010)
New Revision: 2401

Modified:
   core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js
   core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html
Log:
Add baseParams config param to WMSLegend to e.g. support vendor-specific parameters in SLD WMS GetLegendGraphic requests, p=igrcic, r=me (closes #308)

Modified: core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js	2010-09-23 11:55:10 UTC (rev 2400)
+++ core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js	2010-09-24 05:00:08 UTC (rev 2401)
@@ -38,7 +38,7 @@
      *  image/gif.
      */
     imageFormat: "image/gif",
-    
+
     /** api: config[defaultStyleIsFirst]
      *  ``Boolean``
      *  The WMS spec does not say if the first style advertised for a layer in
@@ -56,6 +56,28 @@
      * GetLegendGraphic request? Defaults to true.
      */
     useScaleParameter: true,
+
+    /** api: config[baseParams]
+     * ``Object``
+     * Optional parameters to add to the legend url, this can e.g. be used to
+     *     support vendor-specific parameters in a SLD WMS GetLegendGraphic
+     *     request.
+     *     
+     *  .. code-block:: javascript
+     *     
+     *      var legendPanel = new GeoExt.LegendPanel({
+     *          map: map,
+     *          title: 'Legend Panel',
+     *          defaults: {
+     *              style: 'padding:5px',
+     *              imageFormat: 'image/png',
+     *              baseParams: {
+     *                  LEGEND_OPTIONS: 'forceLabels:on'
+     *              }
+     *          }
+     *      });   
+     */
+    baseParams: null,
     
     /** private: method[initComponent]
      *  Initializes the WMS legend. For group layers it will create multiple
@@ -133,6 +155,10 @@
             url = Ext.urlAppend(url, "SCALE=" + scale);
         }
         
+        if(this.baseParams){
+            url = Ext.urlEncode(this.baseParams, url);
+        }
+        
         return url;
     },
 

Modified: core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html	2010-09-23 11:55:10 UTC (rev 2400)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html	2010-09-24 05:00:08 UTC (rev 2401)
@@ -60,18 +60,32 @@
         }
 
         function test_legendurl(t) {
-            t.plan(7);
+            t.plan(8);
 
             var l, url, expectedUrl;
             var mapPanel = loadMapPanel();
+
             l = new GeoExt.WMSLegend({
                 renderTo: 'legendwms',
+                baseParams: {foo: 'bar bar'},
                 useScaleParameter: false,
                 layerRecord: mapPanel.layers.getAt(0)
             });
             l.render();
 
             url = l.items.get(1).url;
+            expectedUrl = "/ows?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&FORMAT=image%2Fgif&LAYER=a&foo=bar%20bar";
+            t.eq(url, expectedUrl, "GetLegendGraphic url is generated correctly");
+            l.destroy()
+
+            l = new GeoExt.WMSLegend({
+                renderTo: 'legendwms',
+                useScaleParameter: false,
+                layerRecord: mapPanel.layers.getAt(0)
+            });
+            l.render();
+
+            url = l.items.get(1).url;
             expectedUrl = "/ows?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&FORMAT=image%2Fgif&LAYER=a";
             t.eq(url, expectedUrl, "GetLegendGraphic url is generated correctly");
             l.destroy()



More information about the Commits mailing list