I'm working with mapbox android, i'm trying to add multiple waypoints between origin and destination.but after adding one waypoint when it's adding another one this gives the exception " Too many coordinate the s; maximum number of coordinates is 3."
I just want to add multiple waypoint between two point and draw route over those line in mapbox android.
[pastbin link] : https://paste.ubuntu.com/p/PKMQzFyzVb/
My Route Draw Function -->
{
private void getRouteWithWaypoint(Point origin, Point destination, List<Point> wayPoints) {
assert Mapbox.getAccessToken() != null;
NavigationRoute.Builder builder = NavigationRoute.builder(getActivity())
.accessToken(Mapbox.getAccessToken())
.origin(origin)
.destination(destination);
if (wayPoints != null) {
for (Point point : wayPoints) {
builder.addWaypoint(point);
}
}
builder.build().getRoute(new Callback<DirectionsResponse>() {
@Override
public void onResponse(@NonNull Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
Log.e(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;
}
currentRoute = response.body().routes().get(0);
if (navigationMapRoute != null) {
navigationMapRoute.removeRoute();
} else {
navigationMapRoute = new NavigationMapRoute(null, mapView, map, R.style.NavigationMapRoute);
}
navigationMapRoute.addRoute(currentRoute);
}
@SuppressLint("TimberArgCount")
@Override
public void onFailure(Call<DirectionsResponse> call, Throwable t) {
Timber.e(t, "Error: %s");
}
});
}}