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 :)