[OpenLayers-Users] Rules, Styles and context
Andreas Hocevar
ahocevar at opengeo.org
Thu May 27 05:35:58 EDT 2010
Hi,
you are using the context in an incorrect way. Try something like
var context = {
color: function(feature) {
return feature.stylers.color;
}
};
If you have your color in feature.attributes, you don't need a context at all.
Regards,
Andreas.
On May 27, 2010, at 08:49 , James.Sewell at lisasoft.com wrote:
> Hello,
>
> I want to dynamically set a strokeColor based on feature.styler.color rather that feature.attribute.color.
>
> I am using this code:
>
> var context = function(feature) {
> feature.stylers ? ret = feature.stylers : ret = feature.attributes;
> ret ? null : ret = feature;
> return ret;
> }
>
> var defaultStyle = new OpenLayers.Style(OpenLayers.Util.applyDefaults({ strokeColor: "${color}", strokeWidth: 3 }
> , OpenLayers.Feature.Vector.style["default"]), {context: context});
>
> I have also tried this:
>
> var defaultStyle = new OpenLayers.Style(OpenLayers.Util.applyDefaults({ strokeColor: "${color}", strokeWidth: 3 }
> , OpenLayers.Feature.Vector.style["default"]), {context: {styler: null}}) ;
>
> But neither seem to work! I am particularly confused as the top example works for OpenLayers.Rule context manipulation.
>
> Any hints?
>
>
> Cheers,
>
> James Sewell
> LISAsoft Developer
> +61 (3) 8680 3200 / +61 414 688 892
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list