Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Bike/Driving Routes miss out waypoints for routes with more than 9 drops #29

Open
rhigman opened this issue Mar 14, 2024 · 0 comments

Comments

@rhigman
Copy link

rhigman commented Mar 14, 2024

Check a current active route link for any long route for an example. The route starts and ends at the Lockon but the last (n-9) drops will be missing.

Apparently, there's a limit on the number of waypoints a route can have when using the free version of the Maps API (source: lots of stackoverflow etc results for similar complaints).

Possible workarounds:

  1. don't display the Route buttons for longer routes, to avoid confusion
  2. mitigate by removing any duplicate waypoints before calculating route, e.g. at
    const plusCodes = routeData.deliveries.map(item => item.plus_code);
  3. for longer routes, have Route Pt 1/Route Pt 2 buttons? ☹️
  4. attempt a hack: based on aforementioned stackoverflow etc results, I discovered (by fiddling around in the URL bar) that replacing
    const googleRouteUrl = `${ googleRouteBaseUrl }/?api=1&origin=${
    originForUrl
    }&waypoints=${
    plusCodes.map(encodeURIComponent).join('|')
    }&destination=${
    originForUrl
    }`;

    with something like
  const googleRouteUrl     = `${ googleRouteBaseUrl }/{
    originForUrl
  }/{
    plusCodes.map(encodeURIComponent).join('/')
  }/{
    originForUrl
  }`;

does actually show all the waypoints. (It ignores travelmode, though, even when the & is corrected to ?, which would be misleading for cyclists as the default is car.) Using URL hacking rather than the proper API would be brittle, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant