Location context
Navigation SDK for Android is only available upon request. Contact Sales to get started.
While navigating, you can retrieve detailed information about the current location on the road using LocationContext.
The SDK provides location context data such as:
- Current speed
- Speed limit
- Road properties (e.g., number of lanes, functional road class, driving side)
- Address details (e.g., city name, street name, house number)
Refer to the LocationContext API reference for more details.
This guide explains how to use LocationContext to retrieve the city and street names at the current location.
Starting navigation
Before you can retrieve location context information, you need to start navigation with a route. For detailed steps, see the Starting navigation guide.
Instead of adding a listener for route progress updates, make sure you add a LocationContextUpdatedListener to listen for location context updates.
1fun startNavigation() {2 val tomTomNavigation = OnlineTomTomNavigationFactory.create(navigationConfiguration)3 tomTomNavigation.addLocationContextUpdatedListener(locationContextUpdatedListener)45 val routePlan = RoutePlan(route, routePlanningOptions)6 val navigationOptions = NavigationOptions(routePlan)7 tomTomNavigation.start(navigationOptions)8}
Retrieving location context information
Once navigation has started, you can listen for location context updates and retrieve both the city name and the street name at the current location along the route.
1private val locationContextUpdatedListener =2 object : LocationContextUpdatedListener {3 override fun onLocationContextUpdated(locationContext: LocationContext) {4 locationContext.address?.let { address ->5 Log.v(TAG, "city name:" + address.municipality)6 Log.v(TAG, "street name:" + address.streetName)7 }8 }9 }
Next steps
Now that you know how to retrieve location context information, here are the recommendations on what to explore next: