-2

I need the app to generate a route that avoids a specific point/points. Is it possible?

enter image description here

private void getRoute(Point origin, final Point destination) {
    NavigationRoute.builder(this)
            .accessToken(Mapbox.getAccessToken())
            .origin(origin)
            .destination(destination)
            .build()
            .getRoute(new Callback<DirectionsResponse>() {
                @Override
                public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
                    // You can get the generic HTTP info about the 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;
                    }

                    currentRoute = response.body().routes().get(0);

                    // Draw the route on the map
                    if (navigationMapRoute != null) {
                        navigationMapRoute.removeRoute();
                    } else {
                        navigationMapRoute = new NavigationMapRoute(null, mapView, map, R.style.NavigationMapRoute);
                    }
                    navigationMapRoute.addRoute(currentRoute);

                }

                @Override
                public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
                    Log.e(TAG, "Error: " + throwable.getMessage());
                }
            });
}

I need the directions map avoid a specific point when the statusValue = 1, the symbol layer shows(water waves in the pic) and also marks the points as bad route or restricted route. Creating alternative route for the user which finds a way around to destination points. I covered 2 streets, one is in the pic.

Brylle
  • 46
  • 6

1 Answers1

1

No, not really. A very rough experiment you could try is to pass the Directions API coordinates that are away from the point(s) you want to avoid, so that the route avoids those coordinates/areas.

https://docs.mapbox.com/android/java/overview/directions/

langsmith
  • 2,529
  • 1
  • 11
  • 13