Choose an approach
The Mapbox Navigation SDK's core logic and UI elements provide different ways to create a turn-by-turn navigation experience. Various approaches have their own benefits and limitations. This guide will walk you through the options and provide some guidance on how to get started with each.
As a reminder and as explained in the Nav SDK overview, the core part of the Navigation SDK provides navigational logic such as route requesting and determining when the device is off-route. The UI part of the Navigation SDK provides pre-built UI elements.
If the only map in your application is used to facilitate a turn-by-turn navigation experience, Mapbox offers a more customizable approach: the Navigation UI SDK's
- Broad set of customizable options
- Predefined UI elements
- Limited options for modifying
- No seamless access to the
NavigationView class extends the Android
NavigationView is similar to the Maps SDK's
MapView class in terms of creating a map and customizing it. The difference is that the navigation functionality is already built in and does not have to be added via the core Navigation SDK. After initialization of
startNavigation(NavigationViewOptions options) method can be called to start the turn-by-turn navigation experience on the initialized map.
If you want to build a completely customizable turn-by-turn experience, you can use the core Navigation SDK to build standalone navigation components on top of the Maps SDK for Android's
MapView. This approach may also be appropriate if you'd like to integrate components of turn-by-turn navigation into an existing mapping application. For example, you could use the Navigation SDK to request a
DirectionsRoute and use the Maps SDK to draw a two-color gradient line that follows the same path as the
DirectionsRoute, but you don't plan on providing turn-by-turn instructions.
- Completely customizable
- Navigation can be done on same
MapViewthat is used for other tasks
- No out-of-the-box solution
- Layout and function need manual implementation
The interplay of the Maps SDK's
MapView and the navigation logic that's provided by the Navigation SDK's
MapboxNavigation class, creates the most customizable approach to turn-by-turn navigation experiences. This combination brings together the
MapView class, which allows for embedding highly customizable maps, and the full flexibility of the
MapboxNavigation class. This allows you to customize every detail of the navigation experience without having to build it completely from scratch (using Mapbox APIs directly).
- Map: You will need to include a
MapViewelement in your project's layout XML file. You can read more about how to customize
MapViewin the Maps SDK for Android documentation.
- Route: Display a route on the map (Navigation UI SDK's
NavigationMapRoutestandalone component can be used).
- Route events: A
RouteProgressObservercan be attached, which implements callbacks related to route progress. An
OffRouteObservercan also be attached.
- Instructions: To include an
InstructionViewpanel that displays instructions as needed along the route, you will need to include an
InstructionViewelement in your project's layout XML file. This panel can also include navigation icons that show what maneuver to take next. Any icons can be used, but Mapbox offers an open set of icons.
- Route summary: Most turn-by-turn navigation experiences also include a way to view a list of all instructions along with a summary of the distance and time required to complete the route (Navigation UI SDK's
SummaryBottomSheetstandalone component can be used).
- Feedback: You should include a mechanism for users to provide feedback (Navigation UI SDK's
FeedbackBottomSheetstandalone components can be used).
- Voice: You should include instructions for the
NavigationSpeechPlayerto read out loud (Navigation UI SDK's
VoiceInstructionscan be used).
Shows how to combine the Maps SDK with only the Navigation SDK and no Navigation UI SDK code of any kind.