NavigationLocationProvider

class NavigationLocationProvider : LocationProvider

This class provides a LocationProvider implementation that can be used together with the LocationComponentPlugin and provides an easy integration with the LocationObserver that produces enhanced location updates.

Example usage

Initialize the location plugin:

locationComponent = mapView.location.apply {
setLocationProvider(navigationLocationProvider)
addOnIndicatorPositionChangedListener(onIndicatorPositionChangedListener)
puckBearingEnabled = true
enabled = true
}

Pass location data to transition the puck:

private val locationObserver = object : LocationObserver {
override fun onNewRawLocation(rawLocation: Location) {}
override fun onNewLocationMatcherResult(locationMatcherResult: LocationMatcherResult) {
val transitionOptions: (ValueAnimator.() -> Unit)? = if (locationMatcherResult.isTeleport) {
{
duration = 0
}
} else {
{
duration = 1000
}
}
navigationLocationProvider.changePosition(
locationMatcherResult.enhancedLocation,
locationMatcherResult.keyPoints,
latLngTransitionOptions = transitionOptions,
bearingTransitionOptions = transitionOptions
)
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var lastKeyPoints: List<Location>

Returns the last cached key points value.

Link copied to clipboard
var lastLocation: Location?

Returns the last cached target location value.

Functions

Link copied to clipboard
fun changePosition(location: Location, keyPoints: List<Location> = emptyList(), latLngTransitionOptions: ValueAnimator.() -> Unit? = null, bearingTransitionOptions: ValueAnimator.() -> Unit? = null)

Provide the location update that puck should transition to.

Link copied to clipboard
open override fun registerLocationConsumer(locationConsumer: LocationConsumer)

Register the location consumer to the Location Provider.

Link copied to clipboard
open override fun unRegisterLocationConsumer(locationConsumer: LocationConsumer)

Unregister the location consumer from the Location Provider.