Get started with NaviKit SDK

Getting started with NaviKit SDK is very similar to enabling the regular MapKit, though there are some important differences.

Step 1. Get a key for NaviKit SDK

You need an API key to work with NaviKit SDK.

  1. Get the MapKit API key.
  2. You need to activate the API key before you can use it in apps with NaviKit SDK. To do so, contact us at paid-api-maps@yandex-team.ru.

Step 2. Add the NaviKit SDK dependencies

To use all the functions of NaviKit SDK, you need to enable multiple dependencies:

  1. The latest version of NaviKit SDK.

    implementation 'com.yandex.android:maps.mobile:4.6.1-navikit'
    
  2. Google Play services dependency.

    implementation 'com.google.android.gms:play-services-location:21.0.1'
    
  3. A library where NavigationStyleProvider is implemented with UI elements in the signature style of API Maps.

    implementation 'com.yandex.mapkit.styling:automotivenavigation:4.6.1'
    
  4. A library where StyleProvider is implemented for the road events layer with the API Maps icons.

    implementation 'com.yandex.mapkit.styling:roadevents:4.6.1'
    

Sync the project for the changes to apply. After syncing successfully, all the dependencies will be added to your project.

Step 3. Permission to request location

NaviKit SDK for Android requires permission to request locations before it can track the current device location.

  1. Declare permission to use locations in the app's AndroidManifest:

    <manifest ... >
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    </manifest>
    
  2. Request the user's permission to access their location while the app is running.

Step 4. Set up MapKit SDK

Follow the steps from Step 3. Provide the API key to MapKit: install your API key, initialize MapKit, and create a View with the map.

You performed setup correctly if the map opens and the data loads successfully when you run the MapKit app.

Step 5. Note the following

MapKit stores weak references to the Listener objects passed to it. You need to store references to them in memory yourself:

val cameraListener = CameraListener { _, _, _, _ ->
    // ...
}
mapView.mapWindow.map.addCameraListener(cameraListener)

When all the dependencies are installed, you can start using NaviKit SDK in your project.

You can learn about the general architecture of the NaviKit SDK entities in the next section.