[OpenLayers-Users] Features Attributes Matching

Tue Topholm tt at sugee.dk
Wed Dec 26 14:10:27 PST 2012


but try this:

for (var i=0, len = features.length ; i < len; i++)
 {
 if (features[i].attributes.color &&
features[i].attributes.color.indexOf('blue')
>-1) {
  alert('it is a match');
}
}



--

Med venlig hilsen / Kind regards

Tue Topholm
Sugee
Tlf: +45 32 13 32 32
W: http://www.sugee.dk


2012/12/26 Tue Topholm <tt at sugee.dk>

> Have a look how match works:
>
> http://www.w3schools.com/jsref/jsref_match.asp
>
>
> --
>
> Med venlig hilsen / Kind regards
>
> Tue Topholm
> Sugee
> Tlf: +45 32 13 32 32
> W: http://www.sugee.dk
>
>
> 2012/12/26 Xavier Mamano (jorix) <xavier.mamano at gmail.com>
>
> Hi,
>>
>> This means that for some feature has no attribute color,
>>
>> so check before `if(features[i].attributes.color &&
>> features[i].attributes.color.match ...`
>>
>> Regards,
>>
>>
>> I used to filter my features using:
>>
>> for (var i=0; i<features.length; i++)
>>  {
>>  if (features[i].attributes.color == 'blue')
>> .
>> .
>>
>>
>> but sometimes the value could be: dark blue, light blue .. etc
>> So I used match but still can't get it work:
>>
>> var x = "blue";
>>  if (features[i].attributes.color.match(new RegExp(x, "ig")))
>>
>> I get this error:
>> Cannot call method 'match' of undefined
>> </quote>
>>
>>
>>
>> --
>> View this message in context:
>> http://osgeo-org.1560.n6.nabble.com/Features-Attributes-Matching-tp5023291p5024672.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/20121226/bcc86912/attachment.html>


More information about the Users mailing list