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)
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

NavigationLocationProvider
Link copied to clipboard
fun NavigationLocationProvider()

Functions

changePosition
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.
equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open fun hashCode(): Int
registerLocationConsumer
Link copied to clipboard
open override fun registerLocationConsumer(locationConsumer: LocationConsumer)
Register the location consumer to the Location Provider.
toString
Link copied to clipboard
open fun toString(): String
unRegisterLocationConsumer
Link copied to clipboard
open override fun unRegisterLocationConsumer(locationConsumer: LocationConsumer)
Unregister the location consumer from the Location Provider.

Properties

lastKeyPoints
Link copied to clipboard
var lastKeyPoints: List<Location>
Returns the last cached key points value.
lastLocation
Link copied to clipboard
var lastLocation: Location? = null
Returns the last cached target location value.