Hi,
you apply a style to your layer, so you have to change the style of that
layer
function changeRouteColor(color){
var style = routeLayer.style;
style.strokeColor=color;
routeLayer.redraw();
}
I always apply a styleMap to my layers. I didn't know, that it is possible
to apply only a style.
Regards,
Arnd
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von bnoorz
Gesendet: Donnerstag, 23. September 2010 14:56
An: [email protected]
Betreff: [OpenLayers-Users] How to later modify vector layer style
Hi all,
I'm creating a vector layer like this :
var myStyle = {
strokeColor: "#00FF00",
strokeOpacity: 1,
strokeWidth: 4
};
routeLayer = new OpenLayers.Layer.Vector( "Route" );
routeLayer.style=myStyle; map.addLayer(routeLayer);
This works fine.
But , I want to give the user the abaility to change the routes color
dynamically by calling this function :
function changeRouteColor(color){
var style = routeLayer.styleMap.styles["default"].defaultStyle;
style.strokeColor=color;
routeLayer .redraw();
}
.. but this does not work :(
Please help
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/How-to-later-modify-vector-layer-styl
e-tp5562913p5562913.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users