Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Vector Feature Fill Opacity when you have a hexadecimal color

Tags:

openlayers-3

I'm trying to set the fill opacity of a vector feature in OL3 and can't figure out how to do it if I have a hexadecimal value...I've seen examples with rgba. Any suggestions?

Here's what I have:

style : function(feature, resolution) {
          return [new ol.style.Style(
          {
            stroke : new ol.style.Stroke(
            {
              color : feature.get('color'),  
              width : 2
            }),
            fill : new ol.style.Fill(
            {
              color : feature.get('color'), //'#FF0000'
              opacity : 0.2   // I thought this would work, but it's not an option
            })
          })]
        }
like image 636
Jonathan Avatar asked Jan 17 '15 20:01

Jonathan


1 Answers

This is late but might help someone. Using rgba property is also possible.

fill: new ol.style.Fill({color: 'rgba(255, 255, 0, 0.63)'}),
like image 81
wondim Avatar answered Sep 24 '22 15:09

wondim