Invert displayed scale for very high zoom levels

This prevents a scale of '1 : 0' being displayed and instead displays
'scale : 1'
This commit is contained in:
Maximilian Krög
2022-08-06 23:04:25 +02:00
parent 564d9d7685
commit f7cb9b9fdf

View File

@@ -366,8 +366,11 @@ class ScaleLine extends Control {
* @return {string} The stringified HTML of the scalebar. * @return {string} The stringified HTML of the scalebar.
*/ */
createScaleBar(width, scale, suffix) { createScaleBar(width, scale, suffix) {
const resolutionScale = this.getScaleForResolution();
const mapScale = const mapScale =
'1 : ' + Math.round(this.getScaleForResolution()).toLocaleString(); resolutionScale < 1
? Math.round(1 / resolutionScale).toLocaleString() + ' : 1'
: '1 : ' + Math.round(resolutionScale).toLocaleString();
const steps = this.scaleBarSteps_; const steps = this.scaleBarSteps_;
const stepWidth = width / steps; const stepWidth = width / steps;
const scaleSteps = [this.createMarker('absolute')]; const scaleSteps = [this.createMarker('absolute')];