mapbox / mapbox/mapbox-navigation-android

[v1.4.0] zoom level is not set properly at the beginning of navigation

Open
#4,067 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug jira-sync-complete
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Android API:**
30

**Mapbox Navigation SDK version:**

- v1.4.0
- v1.5.0-alpha2

### Steps to trigger behavior

1. Create an app with `NavigationView`
2. Create a route that the next maneuver is far from the origin (that causes zoom less than 15)
3. Start the navigation
4. Notice that the zoom level is still around z15

### Expected behavior

Zoom level should be set to correctly to cover both the origin and the next maneuver.

### Actual behavior

Zoom level keeps around 15 (z15 comes from initial camera setting)

### Additional information

The camera is tried to zoom out both current position and next maneuver is located in a screen (z12 is the minimum) with default [DynamicCamera](https://github.com/mapbox/mapbox-navigation-android/blob/v1.4.0/libnavigation-ui/src/main/java/com/mapbox/navigation/ui/camera/DynamicCamera.java). I create a route that requires z12.2 below but the camera stays almost z15.

```kotlin
val ORIGIN = Point.fromLngLat(139.0373,35.0397)
val DESTINATION = Point.fromLngLat(139.037721,35.126033)
```

I observed following flow;
1. Starting trip session sets z12.2 in [progress observer](https://github.com/mapbox/mapbox-navigation-android/blob/v1.4.0/libnavigation-ui/src/main/java/com/mapbox/navigation/ui/camera/NavigationCamera.java#L101) and start animation
2. Immediately [enhanced location update call back](https://github.com/mapbox/mapbox-navigation-android/blob/v1.4.0/libnavigation-ui/src/main/java/com/mapbox/navigation/ui/camera/NavigationCamera.java#L119) is called and it also tries to [change the zoom](https://github.com/mapbox/mapbox-navigation-android/blob/v1.4.0/libnavigation-ui/src/main/java/com/mapbox/navigation/ui/camera/NavigationCamera.java#L563). Then [this code](https://github.com/mapbox/mapbox-navigation-android/blob/v1.4.0/libnavigation-ui/src/main/java/com/mapbox/navigation/ui/camera/DynamicCamera.java#L70) is called and z15 is returned because current zoom is still 15 (animation has not been stated yet). Finally z12.2 is canceled and keep z15.

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

Reproduce the issue with NavigationView and the supplied origin and destination, then read libnavigation-ui/src/main/java/com/mapbox/navigation/ui/camera/NavigationCamera.java and DynamicCamera.java around the linked progress, location-update, and zoom-selection code. Done means the initial navigation camera uses the zoom needed to show the current position and next maneuver instead of retaining the initial z15 setting.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.