[OpenLayers-Users] how to draw lines of different colors

yvecai yvecai at gmail.com
Sat Jun 4 02:56:28 EDT 2011


On 04. 06. 11 00:19, JK Chen wrote:
>
> Hi,
>
> I have a requirement to draw lines of different colors, such as the 
> one show below (implemented in gmap). Can anyone tell me how to do 
> this in OpenLayers? I have a vector style map, but  can I have more 
> than one, and switch them at run time at drawing? And how?
>
> Or, any other methods able to do same results?
>
>
Something like that:

    var styleContext = {
         getColor: function(feature) {
             //whatever function computing your color
             return "green"
         },
         getOpacity: function(feature) { return 1}
    };
    var styleTemplate = {
         strokeColor: "${getColor}",
         strokeOpacity: "${getOpacity}"
    };
    var myStyle = new OpenLayers.Style(styleTemplate, {context:
    styleContext});

Yves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110604/531e3294/attachment.html


More information about the Users mailing list