[OpenLayers-Users] How to use CQL filter in OpenLayers.Control.WMSGetFeatureInfo?

Asle Benoni asle.benoni at gmail.com
Sat Jun 9 04:13:21 PDT 2012


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%20'%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 <ignacio.talavera at gmail.com>:
> 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 <asle.benoni at gmail.com>
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
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120609/fda41e73/attachment.html>


More information about the Users mailing list