While applications using the Mapbox Navigation SDK for Android don't have to include a map, many use cases will require maps to provide an appropriate navigation experience to your users. After you initialize the Navigation SDK, this guide will help you understand how the Navigation SDK uses the Mapbox Maps SDK and what you need to do to include a map in your application.
By default, the Navigation SDK comes with access to the Mapbox Maps SDK for Android to display routes on a map and show the user's location on the map throughout their trip to provide both navigation-related context and nearby places that may be of interest to the driver.
To add a map to your application, use the Map SDK's
MapView. Open the activity’s XML layout file and add the following:
<com.mapbox.maps.MapView android:id="@+id/mapView" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />
Read more about handling the
MapView lifecycle in the Maps SDK Installation guide.
The Navigation SDK offers several map-related UI components that can enhance the navigation experience for your users.
NavigationCamera is a class that tries to simplify management of the map's camera object in typical navigation scenarios including an overview state (looking at the device location from above) and a following state (zoomed into the device location facing the direction of travel and moving as the location updates).
Whether your users are using your application in free-drive mode without a set route or for turn-by-turn navigation, the SDK allows you to show the user's location updating in real time on a map. Read more in the Device location guide.
If the user is using turn-by-turn navigation, the SDK also provides several components that can be added to the map to orient the user:
- Route line: Invoke the Route Line API to render a route line on a map. See the Draw route lines on a map example.
- Route arrow: Invoke the Route Arrow API when route progress changes to determine when to show an arrow on the route line.
- Buildings: Invoke the Buildings API when route progress changes to highlight the building upon arrival at a waypoint or final destination. See the Render building extrusion on arrival example.
- Signboards: Invoke the Signboard API to include additional visual guidance to the map. Read more in the Extended visual guidance guide.
Because the Navigation SDK includes the full Maps SDK as a dependency, you can completely customize when and how maps are used in your application. For more information on how the Maps SDK works, see the Maps SDK documentation.