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)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11716 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2011-03-18 12:48:17 +00:00
parent 78ab33e8f7
commit 96198dee07
2 changed files with 13 additions and 5 deletions

View File

@@ -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 <OpenLayers.Layer.WMS> 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,

View File

@@ -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");
}
};