Find nearest exit while rerouting navigation in a restricted road using here maps

Viewed 160

I am using here maps android sdk premium version for map navigation in my android app.

I have successfully implemented here maps navigation. While navigating, if I go out of route then reroute calculation occurs and new route to given destination is shown but if I go through a restricted road, then here maps only says rerouting which is true since from restricted road it cannot calculate the route.

But is there any way I can show nearest exit from the restricted road to get a new route to destination on here maps android? Right now, on the restricted roads, no route is shown.

    @Override
    public void onRouteUpdated(@NonNull Route route) {
        Log.d(TAG, "onRouteUpdated: called.");
        //remake new route
        map.removeMapObject(mapRoute);
        // create a new MapRoute object
        mapRoute = new MapRoute(route);
        // display new route on the map
        map.addMapObject(mapRoute);
    }

The above code is not useful while on restricted road. Tried using listener as:

private NavigationManager.RerouteListener rerouteListener = new NavigationManager.RerouteListener() {

    @Override
    public void onRerouteBegin() {
        super.onRerouteBegin();
        Toast.makeText(activity, "reRouteListener begin...", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onRerouteEnd(@NonNull RouteResult routeResult, RoutingError routingError) {
        super.onRerouteEnd(routeResult, routingError);
        StringBuilder stringBuilder = new StringBuilder();
        for (RouteResult.ViolatedOption violatedOption: routeResult.getViolatedOptions()) {
            stringBuilder.append(violatedOption.toString());
        }

        Toast.makeText(activity, "routeresult end: " + stringBuilder, Toast.LENGTH_SHORT).show();
    }
};

Sometimes got violated options as START_DIRECTION and sometimes nothing. But still stuck on how to achieve nearest route as such on restricted road.

[update] : I tried suggestion from @Datasun. But I got invalid routing on initiating new route from restricted road (tried from height restricted road). My problem is while navigating, if user goes to restricted road, the route disappears and it says route recalculating. I want to show user nearest exit from the restricted road or some notification that they are on restricted road. Right now I'm getting violated options of START_DIRECTION but sometimes nothing on the restricted road. What am I missing?

1 Answers

To summarize, within the Navigate SDK the issue is not reproducable any more.

In general the HERE Premium SDK (3.x) is superseded by new 4.x SDK variants and the Premium SDK will be maintained until 31 December 2022 with only critical bug fixes and no feature development / enhancements.

Current users of the HERE Premium SDK (3.x) are encouraged to migrate to Lite, Explore or Navigate HERE SDK (4.x) variants based on licensed use cases before 31 December 2022. Most of the Premium SDK features are already available in the new SDK variants.

Related