RouteControllerDelegate
public protocol RouteControllerDelegate: class
The RouteControllerDelegate
protocol provides methods for responding to significant events during the user’s traversal of a route monitored by a RouteController
.
-
Returns whether the route controller should be allowed to calculate a new route.
If implemented, this method is called as soon as the route controller detects that the user is off the predetermined route. Implement this method to conditionally prevent rerouting. If this method returns
true
,routeController(_:willRerouteFrom:)
will be called immediately afterwards.Declaration
Swift
optional func routeController(_ routeController: RouteController, shouldRerouteFrom location: CLLocation) -> Bool
Parameters
routeController
The route controller that has detected the need to calculate a new route.
location
The user’s current location.
Return Value
True to allow the route controller to calculate a new route; false to keep tracking the current route.
-
Called immediately before the route controller calculates a new route.
This method is called after
routeController(_:shouldRerouteFrom:)
is called, simultaneously with theRouteControllerWillReroute
notification being posted, and beforerouteController(_:didRerouteAlong:)
is called.Declaration
Swift
optional func routeController(_ routeController: RouteController, willRerouteFrom location: CLLocation)
Parameters
routeController
The route controller that will calculate a new route.
location
The user’s current location.
-
Called when a location has been identified as unqualified to navigate on.
See
CLLocation.isQualified
for more information about what qualifies a location.- return: If
true
, the location is discarded and theRouteController
will not consider it. Iffalse
, the location will not be thrown out.
Declaration
Swift
optional func routeController(_ routeController: RouteController, shouldDiscard location: CLLocation) -> Bool
Parameters
routeController
The route controller that discarded the location.
location
The location that will be discarded.
- return: If
-
Called immediately after the route controller receives a new route.
This method is called after
routeController(_:willRerouteFrom:)
and simultaneously with theRouteControllerDidReroute
notification being posted.Declaration
Swift
optional func routeController(_ routeController: RouteController, didRerouteAlong route: Route)
Parameters
routeController
The route controller that has calculated a new route.
route
The new route.
-
Called when the route controller fails to receive a new route.
This method is called after
routeController(_:willRerouteFrom:)
and simultaneously with theRouteControllerDidFailToReroute
notification being posted.Declaration
Swift
optional func routeController(_ routeController: RouteController, didFailToRerouteWith error: Error)
Parameters
routeController
The route controller that has calculated a new route.
error
An error raised during the process of obtaining a new route.
-
Called when the route controller’s location manager receives a location update.
These locations may be modified due to replay or simulation and can also derive from regular location updates from a
CLLocationManager
.Declaration
Swift
optional func routeController(_ routeController: RouteController, didUpdate locations: [CLLocation])
Parameters
routeController
The route controller that received the new locations.
locations
The locations that were received from the associated location manager.
-
Called when the route controller arrives at a waypoint.
You can implement this method to prevent the route controller from automatically advancing to the next leg. For example, you can and show an interstitial sheet upon arrival and pause navigation by returning
false
, then continue the route when the user dismisses the sheet. If this method is unimplemented, the route controller automatically advances to the next leg when arriving at a waypoint.Postcondition
If you return false, you must manually advance to the next leg: obtain the value of therouteProgress
property, then increment theRouteProgress.legIndex
property.Declaration
Swift
optional func routeController(_ routeController: RouteController, didArriveAt waypoint: Waypoint) -> Bool
Parameters
routeController
The route controller that has arrived at a waypoint.
waypoint
The waypoint that the controller has arrived at.
Return Value
True to advance to the next leg, if any, or false to remain on the completed leg.
-
Called when the route controller arrives at a waypoint.
You can implement this method to allow the route controller to continue check and reroute the user if needed. By default, the user will not be rerouted when arriving at a waypoint.
Declaration
Swift
optional func routeController(_ routeController: RouteController, shouldPreventReroutesWhenArrivingAt waypoint: Waypoint) -> Bool
Parameters
routeController
The route controller that has arrived at a waypoint.
waypoint
The waypoint that the controller has arrived at.
Return Value
True to prevent the route controller from checking if the user should be rerouted.