Convert meters to kilometers in route hover

This commit is contained in:
Eugene Burmakin 2024-07-19 20:23:50 +02:00
parent b1f7b98c11
commit 9104e612cb
2 changed files with 10 additions and 2 deletions

File diff suppressed because one or more lines are too long

View file

@ -244,7 +244,7 @@ export default class extends Controller {
<b>Start:</b> ${firstTimestamp}<br>
<b>End:</b> ${lastTimestamp}<br>
<b>Duration:</b> ${timeOnRoute}<br>
<b>Distance:</b> ${Math.round(distance)}m<br>
<b>Distance:</b> ${this.formatDistance(distance)}<br>
`;
if (isDebugMode) {
@ -315,4 +315,12 @@ export default class extends Controller {
})
).addTo(map);
}
formatDistance(distance) {
if (distance >= 1000) {
return (distance / 1000).toFixed(2) + ' km';
} else {
return distance.toFixed(0) + ' meters';
}
}
}