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 here
4 }

To remove a previously-added listener, call TomTomNavigation.removeLocationMapMatchedListener(LocationMapMatchedListener).


To make it easier to provide a map-matched location into the TomTomMap, the Navigation module provides the MapMatchedLocationProvider. It is a special implementation of a LocationProvider that accepts TomTomNavigation.

Before using the MapMatchedLocationProvider, add the module dependency in the build.gradle.kts of your application module and synchronize the project:


Then you can create MapMatchedLocationProvider and use it in the TomTomMap.

val mapMatchedLocationProvider = MapMatchedLocationProvider(navigation = tomTomNavigation)

If SimulationLocationProvider is used in TomTomNavigation, make sure that it is used in TomTomMap instead of MapMatchedLocationProvider.

Next steps

Since you have learned about location tracking, here are recommendations for the next steps: