LaneGuidanceUpdatedListener
Used to inform the caller that lane guidance information has been updated.
This interface provides listeners for when lane guidance starts and ends. Implement this interface to receive notifications when valid lane guidance starts or ends.
The callback methods are only invoked when the SDK calculates valid lane guidance, based on internal filtering criteria. A LaneGuidance is considered valid when:
It happens near a maneuver (e.g., turn, merge, or exit).
It contains multiple lanes (
laneGuidance.lanes.size > 1).It includes valid direction information (e.g.,
RIGHT,STRAIGHT).At least one lane has a recommended direction to follow.
Guidance with only a single lane, no valid directions, or other disqualifying conditions will be ignored and will not trigger callbacks.
Callback details:
onLaneGuidanceStarted(laneGuidance)is called when a new, valid lane guidance becomes active.onLaneGuidanceEnded(laneGuidance)is called when the current lane guidance is no longer relevant.Each
onLaneGuidanceStartedcallback is always followed by a correspondingonLaneGuidanceEndedcallback. before a newonLaneGuidanceStartedis triggered. Callbacks are never stacked or overlapped.
Note: To enable lane guidance updates, make sure GuidanceOptions.extendedSections is set to All via GuidanceOptions. This should be configured when planning the route via RoutePlanningOptions :
val routePlanningOptions = RoutePlanningOptions(
guidanceOptions = GuidanceOptions(
extendedSections = ExtendedSections.All, // Enables lane guidance sections
),
)Example usage of the listener:
val laneGuidanceUpdatedListener = object : LaneGuidanceUpdatedListener {
override fun onLaneGuidanceStarted(laneGuidance: LaneGuidance) {
// Lanes are guaranteed to be non-empty.
val lanes = laneGuidance.lanes
NavigationView.setLanes(lanes)
}
override fun onLaneGuidanceEnded(laneGuidance: LaneGuidance) {
// Clear or update the lane display. Lanes could be empty.
NavigationView.setLanes(laneGuidance)
}
}Register the listener using TomTomNavigation.addLaneGuidanceUpdatedListener. To stop receiving updates, remove the listener using TomTomNavigation.removeLaneGuidanceUpdatedListener.