1

I am trying to implement turn by turn feature into my app using Mapbox Android SDK. Although Mapbox has Drive listed as their product I am not able to find any documentation/examples on how to use it (maybe their are still working on it).

Anyways, I think I need to built it by myself. Getting direction coordinates and drawing poly-lines is all fine. I am stuck here - in the response of the direction api of the Mapbox we have steps json object which contains turn by turn instructions. Lets say there are 3 points under steps object say A,B,C where

  • A = lat1, lng1 (origin)
  • B = lat2, lng2
  • C = lat3, lng3 (destination)

Now, I would like to know how can we identify if we have reached point B so that we can show user the next instruction. I am assuming we just can't do

lat1 == lat2 && lng1 == lng2

Is there any way we can identify when the user reaches a point on the map. I am thinking of adding Geofence on the next point in the list there by getting notified when user enters the Geofence and can update the instruction to the next point in the list and add a Geofence to it too, but I am not sure if its the right approach. Is there any other way we can achieve this ??

Thanks in advance :)

ik024
  • 3,566
  • 7
  • 38
  • 61

1 Answers1

2

You might want to look into our RouteUtils. It includes the basic building blocks of what it's needed for navigation (we're on working on it!). Under the hood, we're using a port of Turf to Java to carry out all the GIS computations.

In your case, you could for example use something like getSnapToRoute() to get the closer point on the step to the user location to compute how far you're from the next turn.

zugaldia
  • 702
  • 3
  • 8
  • Thanks for the ans. Okay wat will getSnapToRoute() return when we cross a point. The return value of the method is Position. Will it return null ?? Just trying to understand. – ik024 Nov 24 '16 at 19:57
  • You should always get a `Position` returned from that method. – cammace Nov 28 '16 at 17:55