Various fixes for browser compatibility issues (#12740)
* Replace Math.log2 with ol/math.log2 * TypedArray.from() browser compatibility fallback * listen for input and change events for range
This commit is contained in:
@@ -77,13 +77,17 @@ const map = new Map({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
distanceInput.addEventListener('input', function () {
|
const distanceHandler = function () {
|
||||||
clusterSource.setDistance(parseInt(distanceInput.value, 10));
|
clusterSource.setDistance(parseInt(distanceInput.value, 10));
|
||||||
});
|
};
|
||||||
|
distanceInput.addEventListener('input', distanceHandler);
|
||||||
|
distanceInput.addEventListener('change', distanceHandler);
|
||||||
|
|
||||||
minDistanceInput.addEventListener('input', function () {
|
const minDistanceHandler = function () {
|
||||||
clusterSource.setMinDistance(parseInt(minDistanceInput.value, 10));
|
clusterSource.setMinDistance(parseInt(minDistanceInput.value, 10));
|
||||||
});
|
};
|
||||||
|
minDistanceInput.addEventListener('input', minDistanceHandler);
|
||||||
|
minDistanceInput.addEventListener('change', minDistanceHandler);
|
||||||
|
|
||||||
map.on('click', (e) => {
|
map.on('click', (e) => {
|
||||||
clusters.getFeatures(e.pixel).then((clickedFeatures) => {
|
clusters.getFeatures(e.pixel).then((clickedFeatures) => {
|
||||||
|
|||||||
@@ -166,10 +166,12 @@ const controlIds = ['hue', 'chroma', 'lightness'];
|
|||||||
controlIds.forEach(function (id) {
|
controlIds.forEach(function (id) {
|
||||||
const control = document.getElementById(id);
|
const control = document.getElementById(id);
|
||||||
const output = document.getElementById(id + 'Out');
|
const output = document.getElementById(id + 'Out');
|
||||||
control.addEventListener('input', function () {
|
const listener = function () {
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
raster.changed();
|
raster.changed();
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
controls[id] = control;
|
controls[id] = control;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -56,10 +56,12 @@ imagery.on('prerender', function (evt) {
|
|||||||
|
|
||||||
const control = document.getElementById('opacity');
|
const control = document.getElementById('opacity');
|
||||||
const output = document.getElementById('output');
|
const output = document.getElementById('output');
|
||||||
control.addEventListener('input', function () {
|
const listener = function () {
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
imagery.setOpacity(control.value / 100);
|
imagery.setOpacity(control.value / 100);
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
imagery.setOpacity(control.value / 100);
|
imagery.setOpacity(control.value / 100);
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,9 @@ const featureOverlay = new VectorLayer({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('time').addEventListener('input', function () {
|
const control = document.getElementById('time');
|
||||||
const value = parseInt(this.value, 10) / 100;
|
const listener = function () {
|
||||||
|
const value = parseInt(control.value, 10) / 100;
|
||||||
const m = time.start + time.duration * value;
|
const m = time.start + time.duration * value;
|
||||||
vectorSource.forEachFeature(function (feature) {
|
vectorSource.forEachFeature(function (feature) {
|
||||||
const geometry =
|
const geometry =
|
||||||
@@ -198,4 +199,6 @@ document.getElementById('time').addEventListener('input', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
map.render();
|
map.render();
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function bindInputs(layerid, layer) {
|
|||||||
visibilityInput.prop('checked', layer.getVisible());
|
visibilityInput.prop('checked', layer.getVisible());
|
||||||
|
|
||||||
const opacityInput = $(layerid + ' input.opacity');
|
const opacityInput = $(layerid + ' input.opacity');
|
||||||
opacityInput.on('input', function () {
|
opacityInput.on('input change', function () {
|
||||||
layer.setOpacity(parseFloat(this.value));
|
layer.setOpacity(parseFloat(this.value));
|
||||||
});
|
});
|
||||||
opacityInput.val(String(layer.getOpacity()));
|
opacityInput.val(String(layer.getOpacity()));
|
||||||
|
|||||||
@@ -57,10 +57,8 @@ aerial.on('postrender', function (event) {
|
|||||||
ctx.restore();
|
ctx.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
swipe.addEventListener(
|
const listener = function () {
|
||||||
'input',
|
map.render();
|
||||||
function () {
|
};
|
||||||
map.render();
|
swipe.addEventListener('input', listener);
|
||||||
},
|
swipe.addEventListener('change', listener);
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -137,7 +137,9 @@ function updateControlValue() {
|
|||||||
}
|
}
|
||||||
updateControlValue();
|
updateControlValue();
|
||||||
|
|
||||||
thresholdControl.addEventListener('input', function () {
|
const listener = function () {
|
||||||
updateControlValue();
|
updateControlValue();
|
||||||
raster.changed();
|
raster.changed();
|
||||||
});
|
};
|
||||||
|
thresholdControl.addEventListener('input', listener);
|
||||||
|
thresholdControl.addEventListener('change', listener);
|
||||||
|
|||||||
@@ -67,10 +67,12 @@ const map = new Map({
|
|||||||
|
|
||||||
const control = document.getElementById('level');
|
const control = document.getElementById('level');
|
||||||
const output = document.getElementById('output');
|
const output = document.getElementById('output');
|
||||||
control.addEventListener('input', function () {
|
const listener = function () {
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
raster.changed();
|
raster.changed();
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
|
|
||||||
raster.on('beforeoperations', function (event) {
|
raster.on('beforeoperations', function (event) {
|
||||||
|
|||||||
@@ -159,10 +159,12 @@ const controls = {};
|
|||||||
controlIds.forEach(function (id) {
|
controlIds.forEach(function (id) {
|
||||||
const control = document.getElementById(id);
|
const control = document.getElementById(id);
|
||||||
const output = document.getElementById(id + 'Out');
|
const output = document.getElementById(id + 'Out');
|
||||||
control.addEventListener('input', function () {
|
const listener = function () {
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
raster.changed();
|
raster.changed();
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
controls[id] = control;
|
controls[id] = control;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -71,10 +71,12 @@ const map = new Map({
|
|||||||
|
|
||||||
const control = document.getElementById('level');
|
const control = document.getElementById('level');
|
||||||
const output = document.getElementById('output');
|
const output = document.getElementById('output');
|
||||||
control.addEventListener('input', function () {
|
const listener = function () {
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
elevation.updateStyleVariables({level: parseFloat(control.value)});
|
elevation.updateStyleVariables({level: parseFloat(control.value)});
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
output.innerText = control.value;
|
output.innerText = control.value;
|
||||||
|
|
||||||
const locations = document.getElementsByClassName('location');
|
const locations = document.getElementsByClassName('location');
|
||||||
|
|||||||
@@ -67,10 +67,12 @@ controlIds.forEach(function (id) {
|
|||||||
variables[id] = Number(control.value);
|
variables[id] = Number(control.value);
|
||||||
}
|
}
|
||||||
updateValues();
|
updateValues();
|
||||||
control.addEventListener('input', () => {
|
const listener = function () {
|
||||||
updateValues();
|
updateValues();
|
||||||
shadedRelief.updateStyleVariables(variables);
|
shadedRelief.updateStyleVariables(variables);
|
||||||
});
|
};
|
||||||
|
control.addEventListener('input', listener);
|
||||||
|
control.addEventListener('change', listener);
|
||||||
});
|
});
|
||||||
|
|
||||||
const map = new Map({
|
const map = new Map({
|
||||||
|
|||||||
@@ -38,18 +38,20 @@ const map = new Map({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const name in variables) {
|
let variable;
|
||||||
|
for (variable in variables) {
|
||||||
|
const name = variable;
|
||||||
const element = document.getElementById(name);
|
const element = document.getElementById(name);
|
||||||
const value = variables[name];
|
const value = variables[name];
|
||||||
element.value = value.toString();
|
element.value = value.toString();
|
||||||
document.getElementById(`${name}-value`).innerText = `(${value})`;
|
document.getElementById(name + '-value').innerText = value.toFixed(2);
|
||||||
|
const listener = function (event) {
|
||||||
element.addEventListener('input', function (event) {
|
|
||||||
const value = parseFloat(event.target.value);
|
const value = parseFloat(event.target.value);
|
||||||
document.getElementById(`${name}-value`).innerText = `(${value})`;
|
document.getElementById(name + '-value').innerText = value.toFixed(2);
|
||||||
|
|
||||||
const updates = {};
|
const updates = {};
|
||||||
updates[name] = value;
|
updates[name] = value;
|
||||||
layer.updateStyleVariables(updates);
|
layer.updateStyleVariables(updates);
|
||||||
});
|
};
|
||||||
|
element.addEventListener('input', listener);
|
||||||
|
element.addEventListener('change', listener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,13 +61,11 @@ const map = new Map({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateSourceDimension = function (source, sliderVal) {
|
const slider = document.getElementById('slider');
|
||||||
source.updateDimensions({'threshold': sliderVal});
|
const updateSourceDimension = function () {
|
||||||
document.getElementById('theinfo').innerHTML = sliderVal + ' meters';
|
wmtsSource.updateDimensions({'threshold': slider.value});
|
||||||
|
document.getElementById('theinfo').innerHTML = slider.value + ' meters';
|
||||||
};
|
};
|
||||||
|
slider.addEventListener('input', updateSourceDimension);
|
||||||
updateSourceDimension(wmtsSource, 10);
|
slider.addEventListener('change', updateSourceDimension);
|
||||||
|
updateSourceDimension();
|
||||||
document.getElementById('slider').addEventListener('input', function () {
|
|
||||||
updateSourceDimension(wmtsSource, this.value);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import {Uniforms} from '../renderer/webgl/TileLayer.js';
|
import {Uniforms} from '../renderer/webgl/TileLayer.js';
|
||||||
import {asArray, isStringColor} from '../color.js';
|
import {asArray, isStringColor} from '../color.js';
|
||||||
|
import {log2} from '../math.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base type used for literal style parameters; can be a number literal or the output of an operator,
|
* Base type used for literal style parameters; can be a number literal or the output of an operator,
|
||||||
@@ -173,7 +174,7 @@ export function getValueType(value) {
|
|||||||
* @return {boolean} True if only one type flag is enabled, false if zero or multiple
|
* @return {boolean} True if only one type flag is enabled, false if zero or multiple
|
||||||
*/
|
*/
|
||||||
export function isTypeUnique(valueType) {
|
export function isTypeUnique(valueType) {
|
||||||
return Math.log2(valueType) % 1 === 0;
|
return log2(valueType) % 1 === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,7 +73,10 @@ class WebGLArrayBuffer {
|
|||||||
* @param {Array<number>} array Numerical array
|
* @param {Array<number>} array Numerical array
|
||||||
*/
|
*/
|
||||||
fromArray(array) {
|
fromArray(array) {
|
||||||
this.array = getArrayClassForType(this.type).from(array);
|
const arrayClass = getArrayClassForType(this.type);
|
||||||
|
this.array = arrayClass.from
|
||||||
|
? arrayClass.from(array)
|
||||||
|
: new arrayClass(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user