I'm trying to get WMSGetFeatureInfo with CQL_FILTER to work correctly. Right now when I click on a result of the CQL_FILTER I get an HTML response with the object attributes.
<html>
<head>
<title>Geoserver GetFeatureInfo output</title>
</head>
<style type="text/css">
table.featureInfo, table.featureInfo td, table.featureInfo th {
border:1px solid #ddd;
border-collapse:collapse;
margin:0;
padding:0;
font-size: 90%;
padding:.2em .1em;
}
table.featureInfo th {
padding:.2em .2em;
font-weight:bold;
background:#eee;
}
table.featureInfo td{
background:#fff;
}
table.featureInfo tr.odd td{
background:#eee;
}
table.featureInfo caption{
text-align:left;
font-size:100%;
font-weight:bold;
text-transform:uppercase;
padding:.2em .2em;
}
</style>
<body>
<table class="featureInfo">
<caption class="featureInfo">ly_parc</caption>
<tr>
<th>fid</th>
<th >PAR_ID</th>
<th >DPTO</th>
<th >DIST</th>
<th >CODLEV</th>
<th >PCATASTRAL</th>
<th >FREGISTRO</th>
</tr>
<tr>
<td>ly_parc.104027</td>
<td>110891.0</td>
<td>K</td>
<td>K03</td>
<td></td>
<td>K03004058</td>
<td>12/20/01 12:00 AM</td>
</tr>
<tr class="odd">
<td>ly_parc.104126</td>
<td>110892.0</td>
<td>K</td>
<td>K03</td>
<td></td>
<td>K03004059</td>
<td>12/20/01 12:00 AM</td>
</tr>
</table>
<br/>
</body>
</html>
That's ok. But when I click on my base layer, outside the result of the CQL_FILTER, I still get an HTML response, but it doesn't have any attributes.
<html>
<head>
<title>Geoserver GetFeatureInfo output</title>
</head>
<style type="text/css">
table.featureInfo, table.featureInfo td, table.featureInfo th {
border:1px solid #ddd;
border-collapse:collapse;
margin:0;
padding:0;
font-size: 90%;
padding:.2em .1em;
}
table.featureInfo th {
padding:.2em .2em;
font-weight:bold;
background:#eee;
}
table.featureInfo td{
background:#fff;
}
table.featureInfo tr.odd td{
background:#eee;
}
table.featureInfo caption{
text-align:left;
font-size:100%;
font-weight:bold;
text-transform:uppercase;
padding:.2em .2em;
}
</style>
<body>
</body>
</html>
I don't want to show anything when the click is fired outside the result of the CQL_FILTER.
This is the code I'm working on rigth now, any thoughts will be helpfull. Thank you.
var options = {
controls: [
//allows user pan/zoom ability
new OpenLayers.Control.Navigation(),
//displays the pan/zoom tools
new OpenLayers.Control.PanZoom(),
],
maxResolution: 936.703125,
displayProjection: WGS84
};
var map = new OpenLayers.Map('map', options);
// Setup single tiled layer
var untiled = new OpenLayers.Layer.WMS(
"cite:ly_parc - Untiled", "http://localhost:8082/geoserver/cite/wms", {
LAYERS: 'cite:ly_parc',
STYLES: '',
format: 'image/png',
transparent : true
}, {
maxExtent: bounds,
isBaseLayer: false
}
);
untiled.mergeNewParams({'CQL_FILTER': "DIST = 'K03'"});
var google_maps = new OpenLayers.Layer.Google(
"Google Maps", {
numZoomLevels: 20
}
);
var info = new OpenLayers.Control.WMSGetFeatureInfo({
title: 'Identify features by clicking',
layers: [untiled],
queryVisible: true,
eventListeners: {
beforegetfeatureinfo: function(event){
this.vendorParams= {CQL_FILTER: "DIST = 'K03'"};
},
getfeatureinfo: function(event) {
alert(event.text);
}
}
});
map.addControl(info);
info.activate();
map.addLayers([google_maps, untiled]);
map.zoomToExtent(bounds);