[OpenLayers-Users] Change color on WFS features?

Pierre GIRAUD bluecarto at gmail.com
Wed Nov 7 09:41:39 EST 2007


Hopefully, features can have their own specific style.

In the current stable version of OpenLayers, you can change the
feature style using the preFeatureInsert callback that comes with the
vector layers (including the WFS one).
Something like the following should help you :

wfs.preFeatureInsert= function(feature) {
    feature.style.strokeWidth="3";
    feature.style.strokeColor="blue";
}

Playing around with this piece of code and with the feature.attribute
property, you should be able to reach your goal.

Regards,
Pierre


On Nov 7, 2007 3:33 PM, Swärd Mårten <marten.sward at smhi.se> wrote:
>
>
>
> Hello folks!
>
> How do I do to change color on a specific feature in a WFS-layer?
>
> If I do it like the code below, then all of the features change color:
>
> layer = new OpenLayers.Layer.WFS(XXXXX);
>
> layer.style = {fillColor:'#FF0000'};
>
> What I want to do is to change color an a feature with a specific value in
> one of it's attributes, but I can't find the features anyware…
>
> Best regards! //Mårten
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



More information about the Users mailing list