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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI 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?
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
});
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