diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index c193ca7922..68b4508391 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -88,7 +88,10 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { /** * 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 instance(s). */ infoFormat: 'text/html', @@ -366,7 +369,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { 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, diff --git a/tests/Control/WMSGetFeatureInfo.html b/tests/Control/WMSGetFeatureInfo.html index dea4b8a41e..cc225e2222 100644 --- a/tests/Control/WMSGetFeatureInfo.html +++ b/tests/Control/WMSGetFeatureInfo.html @@ -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"); } };