I have made a WMS layer using Openlayers2 and Geoserver and I display the layeer using a specific CQL filter.
Now I want to use a WMSGetFeatureInfo request in order to get specific data on click. Although I use the CQL parameters in my WMSGetFeatureInfo request nothing seems to change and I get back all the results.
This is my code:
First I create the layer and added to the map:
cql = "ftth_pop='"+ area+"' AND simul_desc='"+simulation+"'";
layerName2 = 'ngn_marco:out_ducts';
wms = new OpenLayers.Layer.WMS("wms","http://ngn-marco.enomix.gr/geo_wms/",
{
layers: layerName2,
format: "image/png",
transparent: true,
version: "1.1.1",
CQL_FILTER: cql,
tiled: true
},
{
format: "image/png",
displayOutsideMaxExtent: false,
projection: new OpenLayers.Projection("EPSG:900913"),
visibility: true
}
);
map.addLayer(wms);
Then I make the WMSGetFeatureInfo request:
infoControls = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://ngn-marco.enomix.gr/geo_wms/',
title: 'Identify features by clicking',
layer: wms,
CQL_FILTER: cql,
queryVisible: true
})
};
I add the control and activate it as:
for (var i in infoControls) {
infoControls[i].events.register("getfeatureinfo", this, showInfo);
map.addControl(infoControls[i]);
}
infoControls.click.activate();
The showInfo() function is:
function showInfo(evt) {
if (evt.features && evt.features.length) {
highlightLayer.destroyFeatures();
highlightLayer.addFeatures(evt.features);
highlightLayer.redraw();
} else {
//console.log(evt.txt);
document.getElementById('responseText').innerHTML = evt.text;
}
}
The problem is that the CQL filter for the WMSGetFeatureInfo request doesnt work.
EDIT
These are the parameters sent to Geoserver:
BBOX 2637105.178295,4616485.137413,2638971.913845,4617560.033123
FEATURE_COUNT 10
FORMAT image/png
HEIGHT 900
INFO_FORMAT text/html
LAYERS ngn_marco:out_ducts
QUERY_LAYERS ngn_marco:out_ducts
REQUEST GetFeatureInfo
SERVICE WMS
SRS EPSG:900913
STYLES
VERSION 1.1.1
WIDTH 1563
X 715
Y 325
And this is part of the response I get back:
Geoserver GetFeatureInfo output