From 45408201898270c85d3d72fd40be8a6966cd8990 Mon Sep 17 00:00:00 2001 From: "Bernhard R. Fischer" Date: Sun, 16 Feb 2020 12:21:35 +0100 Subject: [PATCH] added display of lat/lon in JS popup (#113) --- images/position.svg | 1 + js/src/mapviewmodel.js | 23 +++++++++++++++++++++++ lang/en.php | 1 + 3 files changed, 25 insertions(+) create mode 100644 images/position.svg diff --git a/images/position.svg b/images/position.svg new file mode 100644 index 0000000..249434f --- /dev/null +++ b/images/position.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/js/src/mapviewmodel.js b/js/src/mapviewmodel.js index 50b68bb..c447c30 100644 --- a/js/src/mapviewmodel.js +++ b/js/src/mapviewmodel.js @@ -188,6 +188,7 @@ export default class MapViewModel extends ViewModel { ${(pos.speed !== null) ? `${$._('speed')}${$.getLocaleSpeed(pos.speed, true)}
` : ''} ${(pos.altitude !== null) ? `${$._('altitude')}${$.getLocaleAltitude(pos.altitude, true)}
` : ''} ${(pos.accuracy !== null) ? `${$._('accuracy')}${$.getLocaleAccuracy(pos.accuracy, true)}${provider}
` : ''} + ${$._('position')} ${MapViewModel.coordStr(pos.latitude, 0)} ${MapViewModel.coordStr(pos.longitude, 1)}
${stats}
${$._('pointof', id + 1, count)}
${editLink}
`; const node = document.createElement('div'); @@ -259,4 +260,26 @@ export default class MapViewModel extends ViewModel { this.api.updateSize(); } } + + + static coordStr(pos, islon) + { + var ipos = Math.floor(pos); + var dec = ((pos - Math.floor(pos)) * 60).toFixed(1); + var dir; + var pad; + + if (islon) + { + dir = pos < 0 ? 'W' : 'E'; + pad = pos < 10 ? '00' : (pos < 100 ? '0' : ''); + } + else + { + dir = pos < 0 ? 'S' : 'N'; + pad = pos < 10 ? '0' : ''; + } + + return pad + ipos + '° ' + (dec < 10 ? '0' : '') + dec + dir; + } } diff --git a/lang/en.php b/lang/en.php index 1f7adcc..371289a 100644 --- a/lang/en.php +++ b/lang/en.php @@ -62,6 +62,7 @@ $lang["close"] = "close"; $lang["time"] = "Time"; $lang["speed"] = "Speed"; $lang["accuracy"] = "Accuracy"; +$lang["position"] = "Position"; $lang["altitude"] = "Altitude"; $lang["ttime"] = "Total time"; $lang["aspeed"] = "Average speed";