[OpenLayers-Users] Filters doesn't work with features attributes

Eric Lemoine eric.lemoine at camptocamp.com
Sun Dec 27 04:56:22 EST 2009


On Wednesday, December 23, 2009, Jimmy Aumard <jimmy.aumard at gmail.com> wrote:
> Hi,
>
> I have problems with filters. I try to create filter dynamically to select many feature on my layer.
>
> Some test code :
>
> var layer=map.getLayersBy('name','franch')[0];
> var filter= new OpenLayers.Filter.Comparison({
>             type: OpenLayers.Filter.Comparison.LIKE,
>             property: "Nom",
>             value: "test"
>         });
> for(i=0;i<layer.features.length;i++){
>     var feature=layer.features[i];
>         alert(feature.attributes.Nom);
>     if(filter.evaluate(feature)){
>     alert('ee');
> }
> }
>
> I have features with an attribute "Nom" = "test" but the filter return alway false.
>
> What I'm doing wrong?

Have you tried passing feature.attributes to the evaluate function?

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list