Friday, 18 October 2019

geoserver - OpenLayers getfeatureinfo shows all features, even with CQL filter


I have a map with several CQL filters that a user can use in my website. When the user applies the CQL filter, I want them to be able to use getfeatureinfo which only shows features from the CQL filter. However, after applying a CQL-filter, it still gives featureinfo of all features, even the ones which are not visible. I looked for solutions here: OpenLayers CQL filter gets info about NOT VISIBLE features and here: How to add CQL filter into GetFeatureInfo request in OpenLayers, but I couldn't solve it myself.


My code looks something like this:


Ext.onReady(function() {

var control_zoom_max = new OpenLayers.Control.ZoomToMaxExtent({title:'Zoom naar het volledige kaartbeeld'});
var control_zoom_in = new OpenLayers.Control.ZoomIn({title:'Zoom gecentreerd in op het kaartbeeld'});

var control_zoom_out = new OpenLayers.Control.ZoomOut({title:'Zoom gecentreerd uit op het kaartbeeld'});
var control_zoom_box = new OpenLayers.Control.ZoomBox({title:'Zoom in met een te slepen rechthoek'});
var control_nav_hist = new OpenLayers.Control.NavigationHistory();
var control_drag_pan = new OpenLayers.Control.DragPan({title:'Verplaats het kaartbeeld met de linkermuisknop'});
var control_identify = new OpenLayers.Control.WMSGetFeatureInfo({
title : 'Klik op een punt of lijn voor informatie',
layers : [ AmiceHerkomst, AmiceVerwerking],
maxFeatures: 1000,
queryVisible : true,
infoFormat : 'application/vnd.ogc.gml',

vendorParams: {
buffer: 5 // geoserver buffer in pixels
},
eventListeners : {
getfeatureinfo : function(event){
showInfo(event);
}
}
});
});


function updateFilter() {
var plaatshtml = document.getElementById('filter').value.toLowerCase();
var volumehtml = document.getElementById('volume').value;
var volumeType = document.getElementById('filterType').value;
var jaar = document.getElementById('Jaar').value;
var maand = document.getElementById('Maand').value;
var bedrijfhtml = document.getElementById('filternaam').value.toLowerCase();

var plaatsnaam = "strToLowerCase(plaats) LIKE '%"+ plaatshtml +"%'";

var volume = "totgw_1 "+ volumeType + " " + volumehtml;
var datum = jaar + maand;
var bedrijfsnaam = "strToLowerCase(straatnm) LIKE '%"+ bedrijfhtml +"%'";

var filterParams = {
cql_filter: null
};

if (OpenLayers.String.trim(plaatshtml) != "") {
filterParams["cql_filter"] = plaatsnaam;

}
if (OpenLayers.String.trim(volumehtml) != ""){
filterParams["cql_filter"] += "AND " + volume;
}
if (OpenLayers.String.trim(bedrijfhtml) != ""){
if (filterParams ["cql_filter"] != null){
filterParams["cql_filter"] += "AND " + bedrijfsnaam;
}
else {
filterParams["cql_filter"] = bedrijfsnaam;

}
}
if (OpenLayers.String.trim(jaar) != ""){
filterParams["cql_filter"] += "AND " + datum;
}

mergeNewParams(filterParams);
}

How do I add my CQL-filter parameters into my getfeatureinfo request?



EDIT this is what the getfeatureinfo request does looking via firebug: enter image description here




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...