Skip to content

Bug: Path Between Destinations Does Not Follow Roads #195

Description

@kirillakovalenko

Description

On the Results page, route polylines are drawn as straight lines connecting each stop
in sequence instead of following the actual road network (streets, turns, one-ways).
This misrepresents the real driving path and makes the on-map distance/route look
nothing like what a driver would actually drive.

The map already intends to draw road-following routes: RoutePolylinesOverlay calls
Google's DirectionsService and only draws a straight polyline as a fallback
(drawFallback, app/ui/src/app/results/components/Map.tsx#L140-L150). In practice every route renders as the fallback,
which means the directions request is either failing, returning no overview_path, or
being skipped. Likely causes to check:

  • Directions API not enabled / not authorized for the Maps API key
    (NEXT_PUBLIC_GOOGLE_MAPS_KEY) — the catch at L224-L230 logs
    "DirectionsService failed, falling back to straight line".
  • Routes with more than 25 waypoints hit the hard fallback at L163-L166.
  • result.routes[0].overview_path empty/missing → fallback at L196-L200.

Goal

Route polylines on the Results page follow the real road network between consecutive
stops instead of drawing straight lines.

Reproduction

Steps

  1. From a clean state, build a route (add addresses + a vehicle) and run Optimize.
  2. Open the Results page.
  3. Observe the route line connecting the depot and each stop on the map.

Expected: The polyline follows the drivable roads and turns between each stop,
matching the path a driver would take.
Actual: The polyline is a straight line directly between each consecutive stop.

Environment: branch main. Check the browser console for the
"DirectionsService failed, falling back to straight line" warning, and confirm whether
the Maps key has the Directions API enabled.

Scope

In scope

  • Diagnose why DirectionsService results aren't being used and ensure road-following
    polylines render for normal routes on the Results page.
  • Confirm the Directions API is enabled/authorized for the configured Maps key (or
    document the required config).

Out of scope

  • Routes exceeding the 25-waypoint Directions limit (the straight-line fallback there
    is acceptable for now; splitting into multiple legs is a separate follow-up).
  • Changing the optimization/solver output or stop ordering.
  • The mobile app and driver-view map.

Acceptance Criteria

  • After running the reproduction steps, the route polyline follows roads/turns
    rather than a straight line.
  • No "DirectionsService failed" warning in the console for a normal (<25 stop) route.
  • On-map route distance reflects the road path (via onRouteDistanceUpdate), not
    straight-line distance.
  • Straight-line fallback still triggers only when directions are genuinely
    unavailable, and does not throw.

Assignee

@KesarSidhu

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions