[OpenLayers-Users] context in Rule

Eric Lemoine eric.lemoine at camptocamp.com
Tue Jan 12 02:22:02 EST 2010


On Mon, Jan 11, 2010 at 8:28 PM, Yves Jacolin (free) <yjacolin at free.fr> wrote:
> Hi,
>
> I would llike to use a context in Rule object. the code below doesn't seems to
> work.
>
> How can I debug this? Do you see something wrong?
>
> var context = {
>   getEvolution: function(feature) {
>     var region = parseInt(((feature.attributes['NBR2009'] -
> feature.attributes['NBR2008']) / feature.attributes['NBR2009'])*100);
>    return region;
>  }
> };
>
> var ruleHigh = new OpenLayers.Rule(
> {
>  context: context,
>  filter: new OpenLayers.Filter.Comparison(
>  {
>      property: '${getEvolution}',
>      type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
>      value: 0,
>  }),
>  symbolizer: {fillColor: "red", fillOpacity: 0.7, strokeColor: "black"}
> });

Looking at your code I feel you want to style each feature based on
the result of some operation on the feature attributes. If so I'd
recommend looking at the styles-context.html example, more
specifically at the way layer2 is styled in this example.

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