How to add below mentioned Mapbox plugins to Android App

405 views Asked by At

I happen unable to add LocationLayerPlugin to my Android project and cannot find any documentation to demonstrate how. Also, I can't find NavigationMapRoute inside package com.mapbox.services.android.navigation.ui.v5. Any help, please?

EDIT:

That's my build.gradle below and when typing LocationLayerPlugin, Android Studio cannot resolve it.

    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar') {
        transitive = true
    }
    compile('com.mapbox.mapboxsdk:mapbox-android-services:2.1.3@aar') {
        transitive = true
    }
    compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.3.1'
1

There are 1 answers

0
cammace On

For the LocationLayerPlugin you can use it with two lines of code:

locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);

You'll need to make sure to also call the lifecycles in the appropriate methods onStart and onStop. If you are using with navigation and want to use location snapping to the route, you will need to pass in null for the locationEngine and than use forceLocationUpdate inside onProgressChange.

A few examples are available here which show different ways to use the plugin. Documentation will be avliable soon once we release the first final version (currently just producing nightly builds).

For the NavigationMapRoute you'll need to make sure you are using the 0.4.0-snapshot of the Navigation SDK. you'll find it here com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute