NavigationViewControllerDelegate
The NavigationViewControllerDelegate
protocol provides methods for configuring the map view shown by a NavigationViewController
and responding to the cancellation of a navigation session.
-
Called when the navigation view controller is dismissed, such as when the user ends a trip.
-
Called as the user approaches a waypoint.
This message is sent, once per progress update, as the user is approaching a waypoint. You can use this to cue UI, to do network pre-loading, etc.
Important
This method will likely be called several times as you approach a destination. If only one consumption of this method is desired, then usage of an internal flag is reccomended. -
Called when the user arrives at the destination waypoint for a route leg.
This method is called when the navigation view controller arrives at the waypoint. You can implement this method to prevent the navigation view 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 navigation view controller automatically advances to the next leg when arriving at a waypoint.Postcondition
If you returnfalse
within this method, you must manually advance to the next leg: obtain the value of thenavigationService
and itsNavigationService.routeProgress
property, then increment theRouteProgress.legIndex
property. -
Returns whether the navigation view controller should be allowed to calculate a new route.
If implemented, this method is called as soon as the navigation view controller detects that the user is off the predetermined route. Implement this method to conditionally prevent rerouting. If this method returns
true
,navigationViewController(_:willRerouteFrom:)
will be called immediately afterwards. -
Called immediately before the navigation view controller calculates a new route.
This method is called after
navigationViewController(_:shouldRerouteFrom:)
is called, simultaneously with theRouteControllerWillReroute
notification being posted, and beforenavigationViewController(_:didRerouteAlong:)
is called. -
Called immediately after the navigation view controller receives a new route.
This method is called after
navigationViewController(_:willRerouteFrom:)
and simultaneously with theRouteControllerDidReroute
notification being posted. -
Called when the navigation view controller fails to receive a new route.
This method is called after
navigationViewController(_:willRerouteFrom:)
and simultaneously with theRouteControllerDidFailToReroute
notification being posted. -
Returns an
MGLStyleLayer
that determines the appearance of the route line.If this method is unimplemented, the navigation view controller’s map view draws the route line using an
MGLLineStyleLayer
. -
Returns an
MGLStyleLayer
that determines the appearance of the route line’s casing.If this method is unimplemented, the navigation view controller’s map view draws the route line’s casing using an
MGLLineStyleLayer
whose width is greater than that of the style layer returned bynavigationViewController(_:routeStyleLayerWithIdentifier:source:)
. -
Returns an
MGLShape
that represents the path of the route line.If this method is unimplemented, the navigation view controller’s map view represents the route line using an
MGLPolylineFeature
based onroute
’scoordinates
property. -
Returns an
MGLShape
that represents the path of the route line’s casing.If this method is unimplemented, the navigation view controller’s map view represents the route line’s casing using an
MGLPolylineFeature
identical to the one returned bynavigationViewController(_:shapeFor:)
. -
-
-
Returns an
MGLShape
that represents the destination waypoints along the route (that is, excluding the origin).If this method is unimplemented, the navigation map view represents the route waypoints using
navigationViewController(_:shapeFor:legIndex:)
. -
Called when the user taps to select a route on the navigation view controller’s map view.
-
Return an
MGLAnnotationImage
that represents the destination marker.If this method is unimplemented, the navigation view controller’s map view will represent the destination annotation with the default marker.
-
Returns a view object to mark the given point annotation object on the map.
The user location annotation view can also be customized via this method. When annotation is an instance of
MGLUserLocation
, return an instance ofMGLUserLocationAnnotationView
(or a subclass thereof). Note that whenNavigationMapView.tracksUserCourse
is set totrue
, the navigation view controller’s map view uses a distinct user course view; to customize it, set theNavigationMapView.userCourseView
property of the map view stored by theNavigationViewController.mapView
property. -
Returns the center point of the user course view in screen coordinates relative to the map view.
-
Allows the delegate to decide whether to ignore a location update.
This method is called on every location update. By default, the navigation view controller ignores certain location updates that appear to be unreliable, as determined by the
CLLocation.isQualified
property. -
Called to allow the delegate to customize the contents of the road name label that is displayed towards the bottom of the map view.
This method is called on each location update. By default, the label displays the name of the road the user is currently traveling on.