TrafficVisualization

public protocol TrafficVisualization : AnyObject, ConformanceLocked

TrafficVisualization defines the protocol for managing and interacting with traffic incident visualizations on a route map.

This protocol provides an interface for enabling/disabling traffic incident visualizations, retrieving traffic incidents for specific routes, and managing observers for tap events on traffic incidents.

  • Enables or disables visualization of on-route traffic incidents. This properity can be changed at any moment of the TrafficVisualization lifecycle. For example, if it is called when no traffic incidents are available (e.g., before displaying a route plan), the new visibility status (either enabled or disabled) is saved and applied later when traffic incidents are available. If it is called when traffic incidents are available (e.g., during the route planning phase), the new status takes effect immediately on the traffic incidents.

    Declaration

    Swift

    var areTrafficIncidentsEnabled: Bool { get set }
  • Gets the list of TrafficIncidents that are being displayed on a certain TomTomSDKRoute/Route.

    Declaration

    Swift

    func trafficIncidents(on route: TomTomSDKRoute.Route) -> [TrafficIncident]

    Parameters

    route

    The TomTomSDKRoute/Route to get traffic incidents from.

    Return Value

    The list of TrafficIncidents on the route, or nil if the route is not in routes.

  • Adds an observer to the list of tap observers.

    This allows external entities to observe and respond to tap events on TrafficSections. When a TrafficSection is tapped, all registered observers are notified.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    func addTrafficIncidentTapObserver(_ observer: TrafficIncidentTapObserver)

    Parameters

    observer

    An object that conforms to the TrafficIncidentTapObserver protocol.

  • Removes an observer from the list of tap observers.

    The specified observer will no longer receive notifications of tap events on TrafficSection.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    func removeTrafficIncidentTapObserver(_ observer: TrafficIncidentTapObserver)

    Parameters

    observer

    An object that conforms to the TrafficIncidentTapObserver protocol to be removed.