メインコンテンツまでスキップ

Maps

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.

Mapbox Maps SDK for Android
Some Mapbox Navigation SDK features integrate with Mapbox Maps SDK. When you install the Navigation SDK, the Maps SDK will also be installed. You do not need to install it separately.

Display a map

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.

Camera

The Navigation Camera is a class that simplifies 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).

Components within the map

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 Location puck on the map 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 Route line guide.
  • Route arrow: Invoke the Route Arrow API when route progress changes to determine when to show an arrow on the route line. See the Route arrow guide.
  • Buildings: Invoke the Buildings API when route progress changes to highlight the building upon arrival at a waypoint or final destination. See the Building highlights guide.

Customize map behavior

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.

この{Type}は役に立ちましたか?