RoutingVisualization

public protocol RoutingVisualization : ConformanceLocked

The Entry point for all methods related to the routing visualization. Instances of RoutingVisualization are created using create(map:styleConfiguration:). RoutingVisualization shouldn’t be conformed outside the TomTom SDK frameworks. Inheritance from TomTomSDKCommon/ConformanceLocked makes it impossible to create RoutingVisualization instances outside the TomTomSDK frameworks. You should call methods on these instances from the main thread only, otherwise an exception can occur. A RoutingVisualization instance is used by first providing a RoutePlan with displayRoutePlan(_:). After that, the TomTomSDKRoute/Routes contained in the RoutePlan are displayed on the map, and you can use setActiveRoute(_:) or selectRoute(_:) to select a route to be navigated on. You can access the list of route primitives displayed on the map using routes or plannedRoutes. The active route and the alternative routes are styled with the properties contained in the StyleConfiguration provided to create(map:styleConfiguration:). You can then call clearRoutePlan() to remove all the primitives that have been added to the map by the module.

Visualization of on-route traffic incidents can be enabled or disabled using areTrafficIncidentsEnabled or traffic api. Visualization of the last reachable point on the route, denoted as a marker, can be toggled on or off using isReachableDistanceMarkerVisible. If a TomTomSDKRoute/Routecontained in the RoutePlan has traffic data available and areTrafficIncidentsEnabled is true, traffic incidents are displayed on the map on top of that TomTomSDKRoute/Route. If a TomTomSDKRoute/Routecontained in the RoutePlan has reachability information and isReachableDistanceMarkerVisible is true, the reachable range marker is displayed on the map on top of that TomTomSDKRoute/Route. You can access the list of traffic incidents that are on a route using trafficIncidents(on:) or using traffic api.

  • The list of TomTomSDKMapDisplay/Routes that is being displayed on the map. During display of a RoutePlan, this list contains the active route and the alternative This list will be empty after calling clear.

    Declaration

    Swift

    @available(*, deprecated, renamed: "plannedRoutes", message: "This API is deprecated and will be removed with the next major release.")
    var routes: [TomTomSDKMapDisplay.Route] { get }
  • The list of TomTomSDKRoute/Routes displayed on the map. During display of a RoutePlan, this list contains the active and alternative routes. This list is empty after calling clear.

    Declaration

    Swift

    var plannedRoutes: [TomTomSDKRoute.Route] { get }
  • The active TomTomSDKMapDisplay/Route. This is nil before a RoutePlan has been displayed with displayRoutePlan(_:), or after calling clearRoutePlan().

    setActiveRoute(_:) For setting a different route to be navigated.

    Declaration

    Swift

    @available(*, deprecated, renamed: "selectedRoute", message: "This API is deprecated and will be removed with the next major release.")
    var activeRoute: TomTomSDKMapDisplay.Route? { get }
  • The selected TomTomSDKRoute/Route. This is nil before a RoutePlan has been displayed with displayRoutePlan(_:), or after calling clearRoutePlan().

    selectRoute(_:) For setting a different route to be navigated.

    Declaration

    Swift

    var selectedRoute: TomTomSDKRoute.Route? { get }
  • Configures whether automatic zoom is enabled. The default is true.

    Declaration

    Swift

    @available(*, deprecated, renamed: "isZoomToRoutesEnabled", message: "This API is deprecated and will be removed with the next major release.")
    var isZoomToRoutePlanEnabled: Bool { get set }
  • Configures whether automatic zoom is enabled. The default is true.

    Declaration

    Swift

    var isZoomToRoutesEnabled: Bool { get set }
  • Enables or disables visualization of on-route traffic incidents. This function can be called at any moment of the RoutingVisualization 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

    @available(*, deprecated, renamed: "traffic.areTrafficIncidentsEnabled", message: "This API is deprecated and will be removed with the next major release.")
    var areTrafficIncidentsEnabled: Bool { get set }
  • Sets whether the route instructions should be visible or hidden. This property can be used dynamically, such as before or after the route planning phase, which means the changes will be applied immediately.

    The default is false.

    Important

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

    Declaration

    Swift

    var areRouteInstructionsVisible: Bool { get set }
  • Provides access to traffic visualization functionalities for the routes displayed on the map.

    This property allows you to interact with the visualization of traffic incidents on the routes managed by the RoutingVisualization instance. It is useful for customizing how traffic information is displayed and for responding to user interactions with traffic incidents.

    Declaration

    Swift

    var traffic: any TrafficVisualization { get }
  • Displays a RoutePlan on the map. Adds a TomTomSDKRoute/Route instance to the map for each TomTomSDKRoute/Route contained in the route plan. By default, the first route of the plan is active, but you can set a different route using setActiveRoute(_:). Consecutive calls of this method replace the previous RoutePlan being displayed. If the provided RoutePlan contains an empty list of routes, then this method does nothing.

    Declaration

    Swift

    func displayRoutePlan(_ routePlan: RoutePlan)

    Parameters

    routePlan

    The RoutePlan to be displayed on the map.

  • Gets the list of TrafficIncidents that are being displayed on a certain TomTomSDKRoute/Route.

    Declaration

    Swift

    @available(*, deprecated, renamed: "traffic.trafficIncidents(on:﹚", message: "This API is deprecated and will be removed with the next major release.")
    func trafficIncidents(on route: TomTomSDKMapDisplay.Route) -> [TrafficIncident]

    Parameters

    route

    The TomTomSDKMapDisplay/Route to get traffic incidents from.

    Return Value

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

  • Set as active a TomTomSDKMapDisplay/Route from the routes displayed on the map. If the provided TomTomSDKMapDisplay/Route is not a route from the RoutePlan displayed with displayRoutePlan(_:), then this method does nothing.

    Declaration

    Swift

    @available(*, deprecated, renamed: "selectRoute(_:﹚", message: "This API is deprecated and will be removed with the next major release.")
    func setActiveRoute(_ route: TomTomSDKMapDisplay.Route)

    Parameters

    route

    The TomTomSDKMapDisplay.Route to be active.

  • Selects a TomTomSDKRoute/Route from the routes displayed on the map. If the provided TomTomSDKRoute/Route is not a route from the RoutePlan displayed with displayRoutePlan(_:), then this method does nothing.

    Declaration

    Swift

    func selectRoute(_ routeId: UUID) -> TomTomSDKRoute.Route?

    Parameters

    routeId

    The UUID of TomTomSDKRoute.Route to be selected.

    Return Value

    The TomTomSDKRoute/Route selected or nil if the route is not in plannedRoutes.

  • Removes all routes and markers added with displayRoutePlan(_:) from the map and sets activeRoute to nil.

    Warning

    Do not remove manually the routes or markers which were added during displayRoutePlan(_:) using TomTomSDKMapDisplay/TomTomMap methods. It may cause unpredictable behavior.

    Declaration

    Swift

    func clearRoutePlan()
  • Removes all alternative routes and corresponding traffic incidents added with displayRoutePlan(_:) from the map and keeps the activeRoute.

    Declaration

    Swift

    func clearAlternativeRoutes()
  • Adds aRouteTapObserver, which will inform when a route primitive is tapped.

    Declaration

    Swift

    func addRouteTapObserver(_ observer: RouteTapObserver)

    Parameters

    observer

    The RouteTapObserver to be added.

  • Removes previously added RouteTapObserver.

    Declaration

    Swift

    func removeRouteTapObserver(_ observer: RouteTapObserver)

    Parameters

    observer

    The RouteTapObserver to be removed.