Geoserver uses cql_filter as far as I remember. Try replacing filter_param with cql_filter and you should be ok
From: [email protected] [mailto:[email protected]] On Behalf Of Asle Benoni Sent: Saturday, June 09, 2012 1:13 PM To: Ignacio Talavera Cc: [email protected] Subject: Re: [OpenLayers-Users] How to use CQL filter in OpenLayers.Control.WMSGetFeatureInfo? Thank you for putting me in this direction. I get an error with your suggested code. missing ; before statement var filter_param["cql_filter"] = "norsknavngruppe LIKE '%Sopp%'; So I tried this: var filter_param = "norsknavngruppe LIKE '%Sopp%'"; info = new OpenLayers.Control.WMSGetFeatureInfo({ url: 'http://kart.naturkart.no/geoserver/wms', title: 'Identify features by clicking', queryVisible: true, infoFormat:'application/vnd.ogc.gml', vendorParams:{ filter_param:filter_param }, eventListeners: { getfeatureinfo: function(event) { if (popup) { map.removePopup(popup); } ......... I get no error and I see (in Firebug) that this is added to the WMS request: &info_format=application%2Fvnd.ogc.gml&filter_param=norsknavngruppe%20LIKE%2 0'%25Sopp%25' Still I get no filtering of the popups and it shows any data that is in the clicked location. I see that the response contains i.ex. <gbif_ns:norsknavngruppe>Lav</gbif_ns:norsknavngruppe> and it should not be included since I only want "norsknavngruppe LIKE '%Sopp%". Is there something wrong with my code? Thanks for any suggestions! 2012/6/8 Ignacio Talavera <[email protected]>: > Hi the WMSGetFeatureInfo manage additionals parameters of the url of the > GetFeatureInfo Request in vendorparams attribute. > So try to add this to your code > > var filter_param["cql_filter"] = prosjektnummer LIKE '%2008-25%' OR > prosjektnavn LIKE '%2008-25% > info = new OpenLayers.Control.WMSGetFeatureInfo({ > url: 'http://kart.naturkart.no/geoserver/wms', > title: 'Identify features by clicking', > queryVisible: true, > infoFormat:'application/vnd.ogc.gml', > vendorParams:filter_param > eventListeners: { > getfeatureinfo: function(event) { > if (popup) { > map.removePopup(popup); > } ........................ > I hope this is useful to you. > Regards > Nacho > On Thu, Jun 7, 2012 at 11:48 AM, Asle Benoni <[email protected]> wrote: >> >> I have made this map: www.babkart.no >> >> I have a search box that on select of the results sends a refresh of >> the layer with CQL parameters to GeoServer. This works. >> But of course when I click I get popups of all the markers, even if >> they are hidden because I understand that I send a WMS request without >> any filter. >> >> So I need help how to use the generated CQL params in my WMS request >> for GetFeautureInfo to GeoServer. >> >> My function CQLfilter in app.js on line 1027 produces this link: >> prosjektnummer LIKE '%2008-25%' OR prosjektnavn LIKE '%2008-25% >> which I use to filter the map. >> >> The question is how I can use this (or IF I can use it!) in my >> function (line 907): >> >> info = new OpenLayers.Control.WMSGetFeatureInfo({ >> url: 'http://kart.naturkart.no/geoserver/wms', >> title: 'Identify features by clicking', >> queryVisible: true, >> infoFormat:'application/vnd.ogc.gml', >> eventListeners: { >> getfeatureinfo: function(event) { >> if (popup) { >> map.removePopup(popup); >> } ........................ >> >> Any ideas on how to use the CQL code here? >> >> ~asle >> _______________________________________________ >> Users mailing list >> [email protected] >> http://lists.osgeo.org/mailman/listinfo/openlayers-users > >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
