[OpenLayers-Users] Making a change of style permanent
Nick Whitelegg
nick at hogweed.org
Sun Apr 15 06:21:28 EDT 2007
On Friday 06 Apr 2007 04:37, you wrote:
> On Thu, Apr 05, 2007 at 11:49:28PM +0100, Nick Whitelegg wrote:
> > 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.
>
> Your code says:
>
> vectorLayer.ways[selectedFeature].style=style;
>
> What you actually mean is:
>
> selectedFeature.style = style;
Bit of a late reply, but I've been working on other aspects of the editor the
past few days. Anyhow, that code I think was from an earlier version of
OpenLayers which used feature IDs, not features.
Anyhow I've corrected it, but the change of style is still not permanent. See
http://www.free-map.org.uk/vector_test/
and try changing the style of any feature. It will change temporarily, but
then when you select something else, it will go back to the old style.
Current code to change the style:
function refreshStyle(xmlHTTP,way)
{
alert('Changes uploaded to server. Response=' +
xmlHTTP.responseText);
var t = way.type;
var colour = vectorLayer.routeTypes.getColour(t);
var width = vectorLayer.routeTypes.getWidth(t);
var style = { fillColor: colour, fillOpacity: 0.4,
strokeColor: colour, strokeOpacity: 1,
strokeWidth: width };
vectorLayer.drawFeature(way,style);
way.style=style;
}
The code to determine the correct colour to use is fine, as the colour does
initially change. But there seems to be something wrong with making the style
permanent - at a guess, there's something wrong with the line
"way.style=style".
Any ideas on this?
Thanks,
Nick
More information about the Users
mailing list