diff --git a/examples/getfeatureinfo.js b/examples/getfeatureinfo.js
index 7cd56c5005..5c9c4b9191 100644
--- a/examples/getfeatureinfo.js
+++ b/examples/getfeatureinfo.js
@@ -1,7 +1,6 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
-goog.require('ol.expr');
goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
diff --git a/src/ol/source/wmssource.js b/src/ol/source/wmssource.js
index 6b28738537..1ca965ecd2 100644
--- a/src/ol/source/wmssource.js
+++ b/src/ol/source/wmssource.js
@@ -72,24 +72,25 @@ ol.source.wms.getUrl =
*/
ol.source.wms.getFeatureInfo = function(url, options, success, opt_error) {
options = goog.isDef(options) ? goog.object.clone(options) : {};
- goog.object.extend(options, {
+ var localOptions = {
method: ol.source.WMSGetFeatureInfoMethod.IFRAME,
params: {}
- });
+ };
+ goog.object.extend(localOptions, options);
var params = {
'INFO_FORMAT': 'text/html'
};
- goog.object.extend(params, options.params);
+ goog.object.extend(params, localOptions.params);
url = goog.uri.utils.appendParamsFromMap(url, params);
// TODO: This could be done in a smarter way if the url function was not a
// closure
url = url.replace('REQUEST=GetMap', 'REQUEST=GetFeatureInfo')
.replace(/LAYERS=([^&]+)/, 'LAYERS=$1&QUERY_LAYERS=$1');
- if (options.method == ol.source.WMSGetFeatureInfoMethod.IFRAME) {
+ if (localOptions.method == ol.source.WMSGetFeatureInfoMethod.IFRAME) {
goog.global.setTimeout(function() {
success('');
}, 0);
- } else if (options.method == ol.source.WMSGetFeatureInfoMethod.XHR_GET) {
+ } else if (localOptions.method == ol.source.WMSGetFeatureInfoMethod.XHR_GET) {
goog.net.XhrIo.send(url, function(event) {
var xhr = event.target;
if (xhr.isSuccess()) {
diff --git a/test/spec/ol/source/wmssource.test.js b/test/spec/ol/source/wmssource.test.js
index cb4a6248ec..2182cb682b 100644
--- a/test/spec/ol/source/wmssource.test.js
+++ b/test/spec/ol/source/wmssource.test.js
@@ -26,8 +26,30 @@ describe('ol.source.wms', function() {
});
});
+ describe('ol.source.wms.getFeatureInfo', function() {
+ it('calls a callback with a feature info IFRAME as result', function(done) {
+ ol.source.wms.getFeatureInfo('?REQUEST=GetMap&LAYERS=foo',
+ {params: {'INFO_FORMAT': 'text/plain'}},
+ function(info) {
+ expect(info).to.eql('');
+ done();
+ });
+ });
+ it('can do xhr to retrieve feature info', function(done) {
+ ol.source.wms.getFeatureInfo('?REQUEST=GetMap&LAYERS=foo', {
+ method: ol.source.WMSGetFeatureInfoMethod.XHR_GET
+ }, function(info) {
+ expect(info).to.contain('');
+ done();
+ });
+ });
+ });
+
});
goog.require('ol.proj');
+goog.require('ol.source.WMSGetFeatureInfoMethod');
goog.require('ol.source.wms');