This error appears when I try to build a NavigationRoute with more than 3 points :
public void buildJourney(Point origin, Point destination, ArrayList<Point> waypoints, Activity v, OnFinishedListener listener)
{
Log.i("BUILD JOURNEY", "LAUNCHED");
NavigationRoute.Builder builder = NavigationRoute.builder(v)
.accessToken(Mapbox.getAccessToken())
.origin(origin)
.destination(destination);
Log.i("BUILD JOURNEY", "Builder created");
for (Point waypoint : waypoints) {
builder.addWaypoint(waypoint);
}
Log.i("BUILD JOURNEY", "Waypoint added");
builder.build().getRoute(new Callback<DirectionsResponse>() {
@Override
public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
Log.d(TAG, "Response code: " + response.code());
if (response.body() == null) {
Log.e(TAG, "No routes found, make sure you set the right user and access token.");
return;
} else if (response.body().routes().size() < 1) {
Log.e(TAG, "No routes found");
return;
}
Log.i("BUILD JOURNEY", "Done");
currentRoute = response.body().routes().get(0);
listener.onRouteCreated(currentRoute);
}
@Override
public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
Log.e(TAG, "Error: " + throwable.getMessage());
}
});
I'm using this versions :
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.7.2'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.26.0'
I've tested all the Point on my wapoints list, they are good; and, on the documentation, they say that we can add 25 coordinates to the NavigationRoute builder.
The only answer I found was to disable the DirectionsCriteria.PROFILE_DRIVING_TRAFFIC parameter, but I didn't activate it, and I think this was an answer from an old version.
Would you know where this error is coming from?
Hey @Florent-Sebag 馃憢 DirectionsCriteria.PROFILE_DRIVING_TRAFFIC is the default in NavigationRoute and has a max of 3 coordinates:
If you'd like to use 25 coordinates, you can adjust the profile to PROFILE_DRIVING:
...
Log.i("BUILD JOURNEY", "LAUNCHED");
NavigationRoute.Builder builder = NavigationRoute.builder(v)
.accessToken(Mapbox.getAccessToken())
.profile(DirectionsCriteria.PROFILE_DRIVING)
.origin(origin)
.destination(destination);
...
Hope this helps, thanks for checking out the SDK!
Changed to .profile(DirectionsCriteria.PROFILE_DRIVING) works for me as well.
Most helpful comment
Hey @Florent-Sebag 馃憢
DirectionsCriteria.PROFILE_DRIVING_TRAFFICis the default inNavigationRouteand has a max of 3 coordinates:https://github.com/mapbox/mapbox-navigation-android/blob/39d8cd01628e62e326bf5bf2be69f619281d8880/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationRoute.java#L69
If you'd like to use 25 coordinates, you can adjust the profile to
PROFILE_DRIVING:Hope this helps, thanks for checking out the SDK!