nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 5dc166de76527a2a935de1ba2f50e918d9281e36
parent 7966cb1934f427e450e068f56f89e039326e1af5
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Sun, 19 Mar 2017 01:24:02 +0300

[print: scale overlay] unit km when scale >= 1000

Diffstat:
Msrc/lib/leaflet.control.printPages/decoration.scale.js | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lib/leaflet.control.printPages/decoration.scale.js b/src/lib/leaflet.control.printPages/decoration.scale.js @@ -7,8 +7,13 @@ class OverlayScale extends PrintStaticLayer { _drawRaster(canvas, printOptions) { const ctx = canvas.getContext('2d'); - const scale = Math.round(printOptions.scale); - let caption = `${scale} m in 1 cm`; + let scale = Math.round(printOptions.scale); + let unit = 'm'; + if (scale >= 1000) { + scale /= 1000; + unit = 'km' + } + let caption = `${scale} ${unit} in 1 cm`; if (printOptions.pagesCount > 1) { caption += ` | Page ${printOptions.pageLabel} / ${printOptions.pagesCount}`; }