From 8685e0b38c5416ef76f62a60a0adb7e6d6451601 Mon Sep 17 00:00:00 2001 From: emoen Date: Tue, 4 Nov 2014 15:12:10 +0100 Subject: [PATCH 1/2] fix to: https://github.com/openlayers/openlayers/issues/1404 Add viewparams to list of params when building url for getFeatureInfo. This enables requesting getFeatureInfo for WMS layers that are from the database - defined as sql-view layers in geoserver. --- lib/OpenLayers/Control/WMSGetFeatureInfo.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index 43f2f3846d..68e6e2bf36 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -350,6 +350,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { height: this.map.getSize().h, width: this.map.getSize().w, format: format, + viewparams: firstLayer.params.VIEWPARAMS, info_format: firstLayer.params.INFO_FORMAT || this.infoFormat }, (parseFloat(firstLayer.params.VERSION) >= 1.3) ? { From b0728ec8b1f9739b45f3b08c342656169bec6a3e Mon Sep 17 00:00:00 2001 From: emoen Date: Fri, 14 Nov 2014 10:52:53 +0100 Subject: [PATCH 2/2] add any non WMS standard parameters to getFeatureInfo requests --- lib/OpenLayers/Control/WMSGetFeatureInfo.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index 68e6e2bf36..2c6b239c66 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -364,6 +364,23 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { y: parseInt(clickPosition.y) } ); + + var len = Object.keys(firstLayer.params).length; + for (var i =0; i < len; i++) { + var otherKey = Object.keys(firstLayer.params)[i]; + if ( !( otherKey == 'LAYERS' || + otherKey == 'TRANSPARENT' || + otherKey == 'STYLES' || + otherKey == 'SERVICE' || + otherKey == 'VERSION' || + otherKey == 'REQUEST' || + otherKey == 'FORMAT' || + otherKey == 'SRS') ) { + + params[otherKey] = firstLayer.params[otherKey]; + } + } + if (layerNames.length != 0) { params = OpenLayers.Util.extend({ layers: layerNames,