Skip to content

0.22.0 Migration Guide

Pablo Guardiola edited this page Dec 21, 2018 · 2 revisions

PRs that broke SEMVER:


The deprecated InstructionView#update(RouteProgress) was removed.

To update the InstructionView (used outside of the NavigationView as its own component), you need to implement two methods now to ensure the View is properly updated with the correct data.

Both ProgressChangeListener and MilestoneEventListener must be implemented. The reason behind this is because we provide banner instruction updates via the MilestoneEventListener (which happens ~2 times a step). The ProgressChangeListener must be implemented as well because it provides the distance remaining data, which is updated every second. Ultimately, this helps with the amount of updates to the TextView and ImageViews in the InstructionView, increasing the UI efficiency.

Code example:

@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
  instructionView.updateDistanceWith(routeProgress);
}

@Override
public void onMilestoneEvent(RouteProgress routeProgress, String instruction, Milestone milestone) {
  instructionView.updateBannerInstructionsWith(milestone);
}

NavigationCamera#updateCameraTrackingEnabled(boolean isEnabled) was replaced with updateCameraTrackingMode(@NavigationCamera.TrackingMode int trackingMode)

This changes the way you enable and disable the NavigationCamera. To do so now, you can alternate between different TrackingModes:

  • NAVIGATION_TRACKING_MODE_NONE: camera does not tack the user location (replaces disabled behavior)
  • NAVIGATION_TRACKING_MODE_GPS: camera tracks the user location, with bearing provided by the location update
  • NAVIGATION_TRACKING_MODE_NORTH: camera tracks the user location, with bearing always set to north (0)

Code example:

// Tracking disabled
camera.updateCameraTrackingMode(NavigationCamera.NAVIGATION_TRACKING_MODE_NONE)

// Tracking enabled 
camera.updateCameraTrackingMode(NavigationCamera.NAVIGATION_TRACKING_MODE_GPS)

NavigationCamera#resetCameraPosition() was replaced with NavigationCamera#resetCameraPositionWith(@TrackingMode int trackingMode):

This change was made so that you can not only reset the camera to its last known position, but also begin tracking again with the mode specified in the param passed.

Code example:

// Moves camera to last known position and begins tracking with bearing 0
camera.resetCameraPositionWith(NavigationCamera.NAVIGATION_TRACKING_MODE_GPS_NORTH)

As a result of these API changes, we also updated NavigationMapboxMap which can be used with NavigationView#retrieveNavigationMap() or by itself as shown in ComponentNavigationActivity. The changes mirror the changes to the NavigationCamera API itself.


In Added nav-native ETAs [RouteLegProgress#durationRemaining()](https://github.com/mapbox/mapbox-navigation-android/pull/1412/files#diff-eb4e0646b51e2ff7104194a9519ed892L69) was made abstract`.