Map-matched location provider
Map-matched locations
Locations provided by a location service have an element of inaccuracy. Using the raw location to update the current user’s position can lead to a position indicator that is unaligned with the Route . To solve this inaccuracy problem, TomTomNavigation produces map-matched locations based on raw locations from the provided LocationProvider . Matched locations are observed through the LocationMapMatchedListener .
val locationMapMatchedListener = LocationMapMatchedListener { mapMatchingResult: MapMatchingResult -> // Your code goes here }tomTomNavigation.addLocationMapMatchedListener(locationMapMatchedListener)To remove a previously-added listener, call TomTomNavigation.removeLocationMapMatchedListener(LocationMapMatchedListener) .
tomTomNavigation.removeLocationMapMatchedListener(locationMapMatchedListener)To make it easier to provide a map-matched location into the TomTomMap , the Navigation module provides the map-matched LocationProvider . It is a special implementation of a LocationProvider that accepts TomTomNavigation .
Before using the map-matched LocationProvider , add the module dependency in the build.gradle.kts of your application module and synchronize the project:
implementation("com.tomtom.sdk.location:provider-map-matched:1.26.4")Then you can create map-matched LocationProvider and use it in the TomTomMap .
val mapMatchedLocationProvider = MapMatchedLocationProviderFactory.create(navigation = tomTomNavigation)tomTomMap.setLocationProvider(mapMatchedLocationProvider)Next steps
Since you have learned about location tracking, here are recommendations for the next steps: