[OpenLayers-Users] Re: drawing polygons with different Colors
Jürgen Dankoweit
Juergen.Dankoweit at T-Online.de
Wed Feb 1 05:34:47 EST 2012
Hello Peter,
Am 01.02.2012 11:12, schrieb Peter:
> hey,
>
> thanks for answering. i tried to change the style attributes like:
>
> function changeColor(vector)
> {
>
> var style = new OpenLayers.Style({fillColor : "red",
> fillOpacity : 0.4});
>
> if(selectedOption == 1)
> {
>
> vector.feature.style = style;
> drawingLayer.redraw();
> }
> }
>
> vector is my drawn polygon and the changeColor method is called with the
> beforefeatureadded event. So it changes the style but then all is black.
>
> Greetings
For me I found an other solution:
http://www.dankoweit.de/Skripte/metarkarte.js
Look at the function "METARKarte_Stationen_erneuern(liste)" in my
script. In this function some icons are renewed and the color of the
label is changed:
l_f = l_Stadt.getFeatureByFid(daten[0]);
if (l_f) {
l_f.attributes.text = daten[4];
l_f.attributes.fcolor = daten[3]; // <-----
l_f.attributes.aktuell = true;
}
and then redraw the layer
First define the color-attribute of the styleMap like this:
fillColor: "\$fcolor"
I hope this will help you a little
Best regards
Jürgen
--
Meine stets unfertige Homepage: www.dankoweit.de
More information about the Users
mailing list