fix(directions): show a 9.96 km route as 10 km, not 10.0 km

routeDistanceText picked one decimal while the raw kilometres were under
10, then rounded them for display, so 9.95 km or more read "10.0 km".
It now picks the unit from the rounded tenth, as it already does at the
metre/kilometre boundary.
This commit is contained in:
Aditya committed 2026-10-28 15:16:45 +05:30
1 parent a4d3701c3c
commit 6364817b5b
3 files changed
+7 -2

No files matched your search

+2 -1
View File
@@ -115,7 +115,8 @@ export function routeDistanceText(meters) {
const tens = Math.round(meters / 10) * 10;
if (tens < 1000) return formatQuantity(tens, 'm');
const km = meters / 1000;
return km < 10
// Pick the unit from the tenth it prints: 9.96 km read "10.0 km".
return Math.round(meters / 100) < 100
? formatQuantity(km, 'km', {
minimumFractionDigits: 1,
maximumFractionDigits: 1,