Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
OpenLayers Color an SVG Icon

I have been following the Icon Colors example on the OpenLayers site, http://openlayers.org/en/latest/examples/icon-color.html?q=color.

This works well for me with png and jpg images, however when I switch to using svg images the color does not change at all. There are no errors. The color just does not change.

Here is the snippet of code where the color change happens:

    /*set the colour*/
    var style = new ol.style.Style({
        image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
            anchor: [0.5, 0.5],
            src : 'img/icons/example.svg',
            color: '#8959A8'
        }))
    }); 

Any advice would be greatly appreciated!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Apparently the fill property for your SVG needs to be white (#fff). The doc doesn't say anything about this but my conclusion is that any white (#fff) will be colorized with the value passed to the color attribute, independently of the type of the image.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!