Use a range input to select the number of steps (1 to 8)

This commit is contained in:
Maximilian Krög
2022-08-06 23:07:25 +02:00
parent 436a4ca597
commit 03a16e3444
3 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import {ScaleLine, defaults as defaultControls} from '../src/ol/control.js';
const scaleBarOptionsContainer = document.getElementById('scaleBarOptions');
const unitsSelect = document.getElementById('units');
const typeSelect = document.getElementById('type');
const stepsSelect = document.getElementById('steps');
const stepsRange = document.getElementById('steps');
const scaleTextCheckbox = document.getElementById('showScaleText');
const invertColorsCheckbox = document.getElementById('invertColors');
@@ -23,7 +23,7 @@ function scaleControl() {
control = new ScaleLine({
units: unitsSelect.value,
bar: true,
steps: parseInt(stepsSelect.value, 10),
steps: parseInt(stepsRange.value, 10),
text: scaleTextCheckbox.checked,
minWidth: 140,
});
@@ -61,6 +61,6 @@ function onInvertColorsChange() {
}
unitsSelect.addEventListener('change', onChangeUnit);
typeSelect.addEventListener('change', reconfigureScaleLine);
stepsSelect.addEventListener('change', reconfigureScaleLine);
stepsRange.addEventListener('input', reconfigureScaleLine);
scaleTextCheckbox.addEventListener('change', reconfigureScaleLine);
invertColorsCheckbox.addEventListener('change', onInvertColorsChange);