Using Openlayers 8.1.0, I've been trying to modify the color of an icon depending on a layer property but I can't get it to work.
Here is my layer constructor :
const marqueursTest = new ol.layer.Vector({
name: 'marqueursTest',
zIndex: 999,
visible: true,
source: sourceWFS,
style: {
'icon-src': 'assets/cavage.png',
'icon-color': [
'case',
['==', ['get', 'roche'], 'calcaire'], [255,153,102],
['==', ['get', 'roche'], 'craie'], [255,230,72],
['==', ['get', 'roche'], 'gypse'], [153,255,102],
['==', ['get', 'roche'], 'autre'], [102,204,255],
[226, 226, 0],
],
},
opacity: 1
});
The icon-src works but the icon color throws the following error :
Uncaught Error: Expected an array of numbers for icon-color
Am I misusing the expressions in this case or are they not supported for icon-color?
According to the doc, it should work but I may have made an error in the syntax since I'm not a professional developer.
Relevant doc and examples are below :
https://openlayers.org/en/v8.1.0/apidoc/module-ol_style_expressions.html
https://openlayers.org/en/v8.1.0/apidoc/module-ol_style_flat.html
https://openlayers.org/en/latest/examples/style-expressions.html