[OpenLayers-Users] Help with changing the color of drawn
features ?
koveras vehcna
silver_fox2006 at hotmail.com
Tue Jul 27 03:31:32 EDT 2010
I fumbled with the controls for a while and then managed to do it the way you
proposed, adding the vector.redraw() made it work. But now, when it draws
the polygons with the colors I select, now I can't draw polygons -the ones
without specifying the number of sides-, lines and points. I can only draw
the regular polygons-with specified sides- and also, if I have drawn two
polygons with different colors, the selected polygons turn into the color of
the last one drawn. How can I tackle this ? I'm posting the code below:
var myStyleMap = new OpenLayers.StyleMap(
new OpenLayers.Style({
fillColor: '${color}',
strokeColor: '${color}'},
//call attribute of style in order to modify
{
context: {
color: function(value) {
if(value == "purple")
{
selectedColor = "purple";
}
else if(value == "blue")
{
selectedColor = "blue";
}
else if(value == "yellow")
{
selectedColor = "yellow";
}
else if(value == "red")
{
selectedColor = "red";
}
else if(value == "orange")
{
selectedColor = "orange";
}
else if(value == "green")
{
selectedColor ="green";
}
// Here define your JS
function that picks the color from the HMTL element
return selectedColor;
vector.redraw();
kamap.redraw();
},
},
}));
many thanks once again.
Cheers,
Koveras
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Help-with-changing-the-color-of-drawn-features-tp5328663p5341139.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list