override URL parameter values in the GetFeatureInfo request if someone provides a param in getFeatureInfoOptions with the same name

This commit is contained in:
Bart van den Eijnden
2013-11-19 14:52:29 +01:00
parent 936f86568e
commit ac730dc1f3
2 changed files with 16 additions and 0 deletions

View File

@@ -95,6 +95,11 @@ ol.source.wms.getFeatureInfo =
goog.object.extend(params, {'X': x, 'Y': y});
}
goog.object.extend(params, localOptions.params);
for (var key in params) {
if (goog.uri.utils.hasParam(url, key)) {
url = goog.uri.utils.removeParam(url, key);
}
}
url = goog.uri.utils.appendParamsFromMap(url, params);
if (localOptions.method == ol.source.WMSGetFeatureInfoMethod.IFRAME) {
goog.global.setTimeout(function() {

View File

@@ -45,6 +45,17 @@ describe('ol.source.wms', function() {
done();
});
});
it('overrides any existing parameters', function(done) {
ol.source.wms.getFeatureInfo('?REQUEST=GetMap&VERSION=1.3&LAYERS=' +
'foo&STYLES=x',
[5, 10], {params: {'INFO_FORMAT': 'text/plain', STYLES: 'y'}},
function(info) {
expect(info).to.eql('<iframe seamless src="' +
'?REQUEST=GetFeatureInfo&VERSION=1.3&LAYERS=foo&QUERY_LAYERS=' +
'foo&INFO_FORMAT=text%2Fplain&I=5&J=10&STYLES=y"></iframe>');
done();
});
});
});
});