Fill Color and Change style of Polygon on OpenLayers Opensource Map

Following code snippets show how to change the filled color and style of polygon on OpenLayers Map. It is tested and working example. :) Thanks.



           //define style for polygon
            var style_poly =
           {
               strokeColor: "#000000",
               strokeOpacity: 1,
               strokeWidth: 2,
               fillColor: "#00FF00",
               fillOpacity: 0.6
            };
            var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
             //------------set style on layer
             polygonLayer.style=style_green;
--------------------------------------------------------------------------------------------------------------

One Response so far.

  1. Anonymous says:

    Thnx. That was something i was looking for quite a time.

    But isn't is rather "polygonLayer.style = style_poly" then "polygonLayer.style = style_green"?

    Where does the "style_green" come from?

    Greetings,

    Alex

Leave a Reply