fix(tours): Google Maps follows a tour on foot or by bike, CoMaps only gets a route it can follow (#2812)

The Google link carried no mode, so a hike opened as a drive, and a stop on
the equator or the prime meridian was dropped. CoMaps routes a start and an
end only; a tour with stops between would reach it as unrouted pins.
This commit is contained in:
Maurice
2026-11-13 10:49:28 +01:00
parent fcbb538c24
commit 5f6594f697
5 changed files with 50 additions and 9 deletions
@@ -39,6 +39,16 @@ describe('tourRouteApps (#2812)', () => {
const targets = tourRouteTargets('bike', line(2), 'Ride');
expect(targets.map((target) => target.id)).toEqual(['google', 'comaps']);
expect(targets.find((target) => target.id === 'comaps')?.url).toContain('type=bicycle');
expect(targets.find((target) => target.id === 'google')?.url).toBe('https://www.google.com/maps/dir/0,0/0,0.01');
expect(targets.find((target) => target.id === 'google')?.url).toBe(
'https://www.google.com/maps/dir/?api=1&origin=0,0&destination=0,0.01&travelmode=bicycling'
);
});
it('FE-TOUR-ROUTEAPPS-005: a longer tour goes to Google on foot with its stops between, and not to CoMaps', () => {
const targets = tourRouteTargets('hike', line(5), 'Ridge');
expect(targets.map((target) => target.id)).toEqual(['google']);
const url = targets[0].url;
expect(url).toContain('&travelmode=walking');
expect(url).toContain('&waypoints=0%2C0.01%7C0%2C0.02%7C0%2C0.03');
});
});
+7 -3
View File
@@ -67,8 +67,9 @@ function spreadIndices(line: ReadonlyArray<readonly [number, number]>, max: numb
/**
* The map apps a tour's route can be opened in, with the tour's mode. Only the
* apps that take the whole route: one that only gets the start (Waze, a geo:
* link) is what the tour's Navigation button already offers.
* apps that route the whole way: one that only gets the start (Waze, a geo:
* link) is what the tour's Navigation button already offers, and CoMaps routes
* a start and an end only, so with stops between it would get unrouted pins.
*/
export function tourRouteTargets(
type: TourTypeKey,
@@ -77,5 +78,8 @@ export function tourRouteTargets(
): DayRouteTarget[] {
const profile = tourAppProfile(type);
if (!profile) return [];
return dayRouteTargets(tourRouteStops(line, name), profile).filter((target) => !target.firstStopOnly);
const stops = tourRouteStops(line, name);
return dayRouteTargets(stops, profile).filter(
(target) => !target.firstStopOnly && !(target.id === 'comaps' && stops.length > 2)
);
}