Programmatically following Google directions?

399 views Asked by At

I'm building an iPad app that will present a screen-by-screen walkthrough of directions sourced from Google's Directions API. I'd like to track the user's progress through physical space using CoreLocation and update the screens to follow the user, similar to most directions applications.

My initial idea is something along these lines:

  1. For each step in the directions, grab the corresponding polyline
  2. When CoreLocation updates, check whether the lat/long pair are within some delta of some point on the polyline (ie, iterate over all the points on the polyline).
  3. If the location is within the polyline, stay on the same screen
  4. If not on the polyline, check whether the user is within the same delta of some subset of the polyline for the next step (say 10 points) and, if so, advance to the next screen.
  5. If not on the next polyline, alert the user that they've left the route.

This seems inefficient and not particularly accurate... Are there better ways to do this?

0

There are 0 answers