mapbox / mapbox/mapbox-navigation-android

Drop-In NavigationView has weird interaction with prefetched route with MapboxNavigation

Open
#6,722 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Android API:** Android 12, Google Pixel 6a
**Mapbox Navigation SDK version:** 2.9.2

So I am experiencing a weird glitch when using NavigationView to create a turn by turn navigation with the Drop-In UI library. My app has a fragment which uses MapView to show a route of delivery. If tapped on start order, the NavigationActivity is called which hosts a NavigationView

The Fragment fetches the route with `mapboxNavigation.requestRoutes()` and sets the navigation route within `onRoutesReady()`

```
mapboxNavigation.requestRoutes(routeOptions, new NavigationRouterCallback() {
@Override
public void onRoutesReady(@NonNull List list, @NonNull RouterOrigin routerOrigin) {
if (list.size() > 0) {
mapboxNavigation.setNavigationRoutes(list);

mainMapBoxMap.getStyle(style1 -> {
routeLineApi.setNavigationRoutes(list, routeValues -> routeLineView.renderRouteDrawData(style1, routeValues));

CoordinateBounds latLngBounds = new CoordinateBounds(
Point.fromLngLat(origin.longitude(), origin.latitude()),
Point.fromLngLat(destination.longitude(), destination.latitude())
);

CameraOptions boundOptions = mainMapBoxMap.cameraForCoordinateBounds(latLngBounds, new EdgeInsets(100, 100, 1200, 100), 0.0, 0.0);
CameraAnimationsUtils.flyTo(mainMapBoxMap, boundOptions, new MapAnimationOptions.Builder().duration(7000).build());

});
} else {
Toast.makeText(getContext(), "Error fetching route", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onFailure(@NonNull List list, @NonNull RouteOptions routeOptions) {

}

@Override
public void onCanceled(@NonNull RouteOptions routeOptions, @NonNull RouterOrigin routerOrigin) {

}
});
```

So here's the issue, when the app lands on NavigationActivity, The NavigationView is kind of zoomed in an doesn't show anything. if the speed limit widget is held, then the bottom sheet opens and we can start the navigation manually. Starting it this way makes it that voice assistance and ManeuverView both works as intended.

https://user-images.githubusercontent.com/119421818/207042025-9a3b27c8-1ec4-4690-8394-a10894a32f93.mp4

However, if the route preview is shown in NavigationActivity with `activityNavigationView.getApi().startRoutePreview(mapboxNavigation.getNavigationRoutes());` and then the start navigation button is tapped, The voice assistance, and manevuerView doesn't work.

https://user-images.githubusercontent.com/119421818/207042288-80e69491-8351-480c-93b6-ec454cdc8edd.mp4

What am I missing here?

### Expected behavior
The manevureView and voice assistance to work properly when route navigation is started for both the cases.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the NavigationActivity NavigationView setup and the route lifecycle around requestRoutes(), onRoutesReady(), setNavigationRoutes(), and startRoutePreview(). Reproduce both startup paths on Android 12 with SDK 2.9.2 and compare their behavior. Done means both paths display the route and make ManeuverView and voice assistance work.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.