I'm using Mapbox Android SDK
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:3.0.0@aar')
.
I asked the similar question before at here, but still have some problem. I don't know how to implement when I get currentRoute. my code is as below:
private Waypoint lastCorrectWayPoint;
private boolean checkOffRoute(Waypoint target) {
boolean isOffRoute = false;
if(currentRoute != null){
if (currentRoute.isOffRoute(target)) {
showMessage("You are off-route, recalculating...");
isOffRoute = true;
lastCorrectWayPoint = null;
//would recalculating route.
} else {
lastCorrectWayPoint = target;
String direction = "Turn right"; //The message what should I prompt to user
double distance = 0.0;//The distance which from target to next step.
int duration = 0;//The time which from target to next step.
String desc = "Turn right to xx street.";
//Implement logic to get them here.
showMessage("direction:" + direction + ", distance:" + distance + ", duration:" + duration + ", desc:" + desc);
}
}
checkOffRoute()
would be called within onLocationChanged()
. I think MapBox SDK should provide these data to developer instead of developer implement it by himself. or if I miss something important information in SDK? Any suggestion?