TrafficVisualization
public protocol TrafficVisualization : AnyObject
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.
Important
This is a Public Preview API. It may be changed or removed at any time.-
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
TrafficIncident
s that are being displayed on a certainTomTomSDKRoute/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
TrafficIncident
s on the route, ornil
if the route is not inroutes
. -
Adds an observer to the list of tap observers.
This allows external entities to observe and respond to tap events on
TrafficSection
s. When aTrafficSection
is tapped, all registered observers are notified.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
.Declaration
Swift
func removeTrafficIncidentTapObserver(_ observer: TrafficIncidentTapObserver)
Parameters
observer
An object that conforms to the
TrafficIncidentTapObserver
protocol to be removed.