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.
- Get the MapKit API key.
- You need to activate the API key before you can use it in apps with NaviKit SDK. To do so, contact us at sales@mappable.world.
Step 2. Add the NaviKit SDK dependencies
To use all the functions of NaviKit SDK, you need to enable multiple dependencies:
-
The latest version of NaviKit SDK.
implementation 'world.mappable.android:maps.mobile:1.1.0-navikit'
-
Google Play services dependency.
implementation 'com.google.android.gms:play-services-location:21.0.1'
-
A library where NavigationStyleProvider is implemented with UI elements in the signature style of API Maps.
implementation 'world.mappable.mapkit.styling:automotivenavigation:1.1.0'
-
A library where StyleProvider is implemented for the road events layer with the API Maps icons.
implementation 'world.mappable.mapkit.styling:roadevents:1.1.0'
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.
-
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>
-
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.