4

I have created a polygon using Vector layer in OpenLayers 3 now I have to fill that polygon with red color. But I cannot do this using style option in OpenLayers 3.

Any one have any idea how to do this?

  • 2
    From this link, I'm guessing to fill it would be something like: var fill = new ol.style.Fill({color: 'rgba(50, 100, 150, 0.50)'});. But don't quote me on this :) – Joseph Dec 11 '14 at 10:40
1

You must define a ol.styleStyle object, which again consist of an ol.style.Fill and an ol.style.Stroke object. In the OL3 documentation you must unclick the "Stable only" field in the upper right corner to see the full documentation.

_myStroke = new ol.style.Stroke({
   color : 'rgba(255,0,0,1.0)',
   width : 1    
});

_myFill = new ol.style.Fill({
   color: 'rgba(255,0,0,1.0)'
});

myStyle = new ol.style.Style({
   stroke : _myStroke,
   fill : _myFill
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.