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.
1val locationMapMatchedListener =2 LocationMapMatchedListener { mapMatchingResult: MapMatchingResult ->3 // Your code goes here4 }5tomTomNavigation.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.2")
Then you can create map-matched LocationProvider and use it in the TomTomMap.
val mapMatchedLocationProvider = MapMatchedLocationProviderFactory.create(navigation = tomTomNavigation)tomTomMap.setLocationProvider(mapMatchedLocationProvider)
If
SimulationLocationProvideris used inTomTomNavigation, make sure that it is used inTomTomMapinstead of map-matchedLocationProvider.
Next steps
Since you have learned about location tracking, here are recommendations for the next steps: