[OpenLayers-Commits] r11716 - in trunk/openlayers: lib/OpenLayers/Control tests/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Mar 18 08:48:18 EDT 2011


Author: bartvde
Date: 2011-03-18 05:48:17 -0700 (Fri, 18 Mar 2011)
New Revision: 11716

Modified:
   trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js
   trunk/openlayers/tests/Control/WMSGetFeatureInfo.html
Log:
WMSGetFeatureInfo Control does not allow for different infoFormats per layer, r=erilem, thanks erilem for the quick review, api docs now have instructions for this (closes 3176)

Modified: trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js	2011-03-17 18:28:20 UTC (rev 11715)
+++ trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js	2011-03-18 12:48:17 UTC (rev 11716)
@@ -88,7 +88,10 @@
 
     /**
      * Property: infoFormat
-     * {String} The mimetype to request from the server
+     * {String} The mimetype to request from the server. If you are using 
+     * drillDown mode and have multiple servers that do not share a common 
+     * infoFormat, you can override the control's infoFormat by providing an 
+     * INFO_FORMAT parameter in your <OpenLayers.Layer.WMS> instance(s).
      */
     infoFormat: 'text/html',
     
@@ -366,7 +369,7 @@
             height: this.map.getSize().h,
             width: this.map.getSize().w,
             format: format,
-            info_format: this.infoFormat
+            info_format: firstLayer.params.INFO_FORMAT || this.infoFormat
         }, (parseFloat(firstLayer.params.VERSION) >= 1.3) ?
             {
                 crs: projection,

Modified: trunk/openlayers/tests/Control/WMSGetFeatureInfo.html
===================================================================
--- trunk/openlayers/tests/Control/WMSGetFeatureInfo.html	2011-03-17 18:28:20 UTC (rev 11715)
+++ trunk/openlayers/tests/Control/WMSGetFeatureInfo.html	2011-03-18 12:48:17 UTC (rev 11716)
@@ -420,7 +420,7 @@
     }
 
     function test_drillDown(t) {
-        t.plan(4);
+        t.plan(6);
         var map = new OpenLayers.Map("map", {
             getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
             }
@@ -434,14 +434,17 @@
             layers: "c"
         });
 
+        // this service does not support application/vnd.ogc.gml for GetFeatureInfo, only text/xml
         var c = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", {
-            layers: "x"
+            layers: "x",
+            info_format: "text/xml"
         });
 
         map.addLayers([a, b, c]);
 
         var click = new OpenLayers.Control.WMSGetFeatureInfo({
-            drillDown: true
+            drillDown: true,
+            infoFormat: "application/vnd.ogc.gml"
         });
 
         map.addControl(click);
@@ -451,9 +454,11 @@
         OpenLayers.Request.GET = function(options) {
             count++;
             if (count == 1) {
+                t.eq(options.params["INFO_FORMAT"], "application/vnd.ogc.gml", "Default info format of the control is used");
                 t.eq(options.params["QUERY_LAYERS"].join(","), "a,c", "Layers should be grouped by service url");
                 t.eq(options.url, "http://localhost/wms", "Correct url used for first request");
             } else if (count == 2) {
+                t.eq(options.params["INFO_FORMAT"], "text/xml", "Overridden info format is used instead of the control's infoFormat");
                 t.eq(options.url, "http://myhost/wms", "Correct url used for second request");
             }
         };



More information about the Commits mailing list