| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 
 | import GeoTIFF from 'ol/source/GeoTIFF.js';import Map from 'ol/Map.js';
 import TileLayer from 'ol/layer/WebGLTile.js';
 import View from 'ol/View.js';
 
 const channels = ['red', 'green', 'blue'];
 for (const channel of channels) {
 const selector = document.getElementById(channel);
 selector.addEventListener('change', update);
 
 const input = document.getElementById(`${channel}Max`);
 input.addEventListener('input', update);
 }
 
 function getVariables() {
 const variables = {};
 for (const channel of channels) {
 const selector = document.getElementById(channel);
 variables[channel] = parseInt(selector.value, 10);
 
 const inputId = `${channel}Max`;
 const input = document.getElementById(inputId);
 variables[inputId] = parseInt(input.value, 10);
 }
 return variables;
 }
 
 const layer = new TileLayer({
 style: {
 variables: getVariables(),
 color: [
 'array',
 ['/', ['band', ['var', 'red']], ['var', 'redMax']],
 ['/', ['band', ['var', 'green']], ['var', 'greenMax']],
 ['/', ['band', ['var', 'blue']], ['var', 'blueMax']],
 1,
 ],
 },
 source: new GeoTIFF({
 normalize: false,
 sources: [
 {
 url: 'https://s2downloads.eox.at/demo/EOxCloudless/2020/rgbnir/s2cloudless2020-16bits_sinlge-file_z0-4.tif',
 },
 ],
 }),
 });
 
 function update() {
 layer.updateStyleVariables(getVariables());
 }
 
 const map = new Map({
 target: 'map',
 layers: [layer],
 view: new View({
 projection: 'EPSG:4326',
 center: [0, 0],
 zoom: 2,
 maxZoom: 6,
 }),
 });
 
 |