From a34b82f52be29ee9935119e0954a00d43a9e72ae Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 17 Jun 2025 20:09:55 +0200 Subject: Add comment. --- main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 1c9fbab..b1d466f 100644 --- a/main.js +++ b/main.js @@ -3440,8 +3440,11 @@ const infoMetadataAccordions = []; const n = Math.max(...indices.map(([i]) => i)); const palette = new Array(n+1).fill(nodata); indices.forEach(([i,l]) => palette[i] = styles[l] ?? nodata); - /* XXX unfortunately calling .setStyle() makes the layer blink */ - lyr.setStyle({ color: ['palette', ['band', 1], palette ] }); + /* XXX unfortunately calling .setStyle() makes the layer blink; using style variabse would + * be nicer, but `['palette', ['band', 1], [['var', 'val1'], …]]` fails as each palette index + * needs to be a color literal, even when `['var', 'val1']` evaluates to such, cf. + * https://github.com/openlayers/openlayers/blob/v10.6.0/src/ol/expr/expression.js#L976 */ + lyr.setStyle({ color: ['palette', ['band', 1], palette] }); } }); Object.entries(LAYERS).forEach(function([k,v]) { -- cgit v1.2.3