[OpenLayers-Users] Re: Filtering a vector Layer

Aparna aparna.mookerjee at gmail.com
Mon Feb 20 23:21:10 EST 2012


Here is an example.

The WFS layer

var state = new OpenLayers.Layer.Vector("Karnataka", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                filter:"",
                protocol: new OpenLayers.Protocol.WFS({
                    version: "1.1.0",
                    url: "http://Aparna:8085/geoserver/wfs",

                    featureType: "detail",
                    featureNS: "http://opengeo.org/India"

                })

            });

next what I have is a checkbox that is used to filter the layer
I have an array that added the value of every checkbox on the click event.

var list = '';
                $('#schcat input[type="checkbox"]:checked').each(function(){
                list += $('#schcat').attr('id').toUpperCase() +"="
+($(this).val()) + ' OR '
                });
                str =list.substring(0,list.length-3);
                //alert(str);
                var x= str.length;

If the length of the array is greater than zero then filter the layers

               var newfilter=format.read(str);
                map.layers[2].filter=newfilter;
                map.layers[2].refresh({force:true});







On Sun, Feb 19, 2012 at 9:43 PM, Shadin <w_ward_W at hotmail.com> wrote:

> would you please give more details about how to do it ?
> where did you put the filter ?
>
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/Filtering-a-vector-Layer-tp3911020p4485406.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> 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/20120221/921f2400/attachment.html


More information about the Users mailing list