[OpenLayers-Users] Making a change of style permanent

Nick Whitelegg nick at hogweed.org
Thu Apr 5 18:49:28 EDT 2007


Having a bit of difficulty making style changes of LineString features 
permanent. When a user changes the properties of a LineString feature 
representing a road or path, I want it to change colour appropriately (each 
type of LineString feature is represented in a different colour).

To attempt to do this, I have used the following code:

var style = { fillColor: colour, fillOpacity: 0.4,
							strokeColor: colour, strokeOpacity: 1,
							strokeWidth: width };

// Redraw selected feature in new colour
vectorLayer.redrawFeature(selectedFeature,style);

// Try to make the style permanent
vectorLayer.ways[selectedFeature].style=style;

where colour and width are the new colour and width. The first line, redrawing 
the feature, works - but the attempt to make the style permanent with the 
second line does not work. When you select another feature, the feature which 
you changed the properties of goes back to the original colour.

For example if you go to http://www.free-map.org.uk/vector/, choose the 
"select" button, click on a green line, choose the "change" button and type 
in "bridleway", it will change from green to brown, but then, when you select 
another line, it will go back to the original green.

Any ideas on this?

Thanks,
Nick



More information about the Users mailing list