Merge lat/lon in JS popup

This commit is contained in:
Bartek Fabiszewski 2020-02-16 12:36:24 +01:00
commit 5447a9a5fc
4 changed files with 30 additions and 0 deletions

1
images/position.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 0c-4.198 0-8 3.403-8 7.602 0 4.198 3.469 9.21 8 16.398 4.531-7.188 8-12.2 8-16.398 0-4.199-3.801-7.602-8-7.602zm0 11c-1.657 0-3-1.343-3-3s1.343-3 3-3 3 1.343 3 3-1.343 3-3 3z"/></svg>

After

Width:  |  Height:  |  Size: 279 B

View File

@ -135,4 +135,30 @@ export default class uLang {
return ((d > 0) ? (`${d} ${this.unit('unitDay')} `) : '') +
((`00${h}`).slice(-2)) + ':' + ((`00${m}`).slice(-2)) + ':' + ((`00${s}`).slice(-2)) + '';
}
/**
* @param {uPosition} pos
* @return {string}
*/
getLocaleCoordinates(pos) {
return `${uLang.coordStr(pos.longitude, true)} ${uLang.coordStr(pos.latitude, false)}`;
}
/**
* @param {number} pos
* @param {boolean} isLon
* @return {string}
*/
static coordStr(pos, isLon) {
const ipos = Math.floor(pos);
const dec = ((pos - ipos) * 60).toFixed(1);
let dir;
if (isLon) {
dir = pos < 0 ? 'W' : 'E';
} else {
dir = pos < 0 ? 'S' : 'N';
}
return `${ipos}° ${dec}'${dir}`;
}
}

View File

@ -188,6 +188,7 @@ export default class MapViewModel extends ViewModel {
${(pos.speed !== null) ? `<img class="icon" alt="${$._('speed')}" title="${$._('speed')}" src="images/speed_dark.svg">${$.getLocaleSpeed(pos.speed, true)}<br>` : ''}
${(pos.altitude !== null) ? `<img class="icon" alt="${$._('altitude')}" title="${$._('altitude')}" src="images/altitude_dark.svg">${$.getLocaleAltitude(pos.altitude, true)}<br>` : ''}
${(pos.accuracy !== null) ? `<img class="icon" alt="${$._('accuracy')}" title="${$._('accuracy')}" src="images/accuracy_dark.svg">${$.getLocaleAccuracy(pos.accuracy, true)}${provider}<br>` : ''}
<img class="icon" alt="${$._('position')}" title="${$._('position')}" src="images/position.svg">${$.getLocaleCoordinates(pos)}<br>
</div>${stats}</div>
<div id="pfooter"><div>${$._('pointof', id + 1, count)}</div><div>${editLink}</div></div>`;
const node = document.createElement('div');
@ -259,4 +260,5 @@ export default class MapViewModel extends ViewModel {
this.api.updateSize();
}
}
}

View File

@ -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";