[OpenLayers-Users] rules depending on state

Andreas Hocevar andreas.hocevar at gmail.com
Wed May 14 16:26:56 EDT 2008


Pierre GIRAUD wrote:
> I don't think this is that simple.
> To me, we can't define a context in addUniqueValueRules because it has
> no knowledge of individual features.
>   

It does not have to. But there is still something missing. Filters would 
have to do a similar check for a function type context like in 
http://trac.openlayers.org/changeset/6512#file1.

Once we have that, the following modified version of addUniqueValueRules 
should do the trick:

    addUniqueValueRules: function(renderIntent, property, symbolizers,
            context) {
        var rules = [];
        for (var value in symbolizers) {
            rules.push(new OpenLayers.Rule({
                symbolizer: symbolizers[value],
                context: context,
                filter: new OpenLayers.Filter.Comparison({
                    type: OpenLayers.Filter.Comparison.EQUAL_TO,
                    property: property,
                    value: value
                })
            }));
        }
        this.styles[renderIntent].addRules(rules);
    },


> I can't find any example where a context is defined at OpenLayers.Rule
> instantiation.
>   

You're right, that is missing somehow, because the rules context is not 
very useful the way it is now.


Regards,
Andreas.



More information about the Users mailing list