diff --git a/examples/scale-line.css b/examples/scale-line.css index 03c39ff5d1..e995aba680 100644 --- a/examples/scale-line.css +++ b/examples/scale-line.css @@ -1,3 +1,11 @@ #scaleBarOptions { display: none; } + +.ol-scale-bar-inverted .ol-scale-singlebar-even { + background-color: var(--ol-background-color); +} + +.ol-scale-bar-inverted .ol-scale-singlebar-odd { + background-color: var(--ol-subtle-foreground-color);; +} diff --git a/examples/scale-line.html b/examples/scale-line.html index f31a77aca6..3d601b7049 100644 --- a/examples/scale-line.html +++ b/examples/scale-line.html @@ -31,4 +31,6 @@ tags: "scale-line, openstreetmap" + + diff --git a/examples/scale-line.js b/examples/scale-line.js index 2f4af685c0..7405e9b785 100644 --- a/examples/scale-line.js +++ b/examples/scale-line.js @@ -9,6 +9,7 @@ const unitsSelect = document.getElementById('units'); const typeSelect = document.getElementById('type'); const stepsSelect = document.getElementById('steps'); const scaleTextCheckbox = document.getElementById('showScaleText'); +const invertColorsCheckbox = document.getElementById('invertColors'); let control; @@ -26,6 +27,7 @@ function scaleControl() { text: scaleTextCheckbox.checked, minWidth: 140, }); + onInvertColorsChange(); scaleBarOptionsContainer.style.display = 'block'; } return control; @@ -51,7 +53,14 @@ function reconfigureScaleLine() { function onChangeUnit() { control.setUnits(unitsSelect.value); } +function onInvertColorsChange() { + control.element.classList.toggle( + 'ol-scale-bar-inverted', + invertColorsCheckbox.checked + ); +} unitsSelect.addEventListener('change', onChangeUnit); typeSelect.addEventListener('change', reconfigureScaleLine); stepsSelect.addEventListener('change', reconfigureScaleLine); scaleTextCheckbox.addEventListener('change', reconfigureScaleLine); +invertColorsCheckbox.addEventListener('change', onInvertColorsChange);