NavigationViewControllerDelegate
The NavigationViewControllerDelegate protocol provides methods for configuring the map view shown by a NavigationViewController and responding to the cancellation of a navigation session.
For convenience, several location-related methods in the NavigationServiceDelegate protocol have corresponding methods in this protocol.
-
navigationViewControllerDidDismiss(_:byCanceling:)Default implementationCalled when the navigation view controller is dismissed, such as when the user ends a trip.
Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:didUpdate:with:rawLocation:)Default implementationCalled when movement of the user updates the route progress model.
Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:willArriveAt:after:distance:)Default implementationCalled 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.
Note
This method will likely be called several times as you approach a destination. To respond to the user’s arrival only once, your delegate can define a property that keeps track of whether this method has already been called for the given waypoint.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:didArriveAt:)Default implementationCalled 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 returnfalsewithin this method, you must manually advance to the next leg: obtain the value of thenavigationServiceand itsNavigationService.routeProgressproperty, then increment theRouteProgress.legIndexproperty.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:shouldRerouteFrom:)Default implementationReturns 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.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:willRerouteFrom:)Default implementationCalled immediately before the navigation view controller calculates a new route.
This method is called after
navigationViewController(_:shouldRerouteFrom:)is called, simultaneously with theRouteControllerWillReroutenotification being posted, and beforenavigationViewController(_:didRerouteAlong:)is called.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:didRerouteAlong:)Default implementationCalled immediately after the navigation view controller receives a new route.
This method is called after
navigationViewController(_:willRerouteFrom:)and simultaneously with theRouteControllerDidReroutenotification being posted.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:didFailToRerouteWith:)Default implementationCalled when the navigation view controller fails to receive a new route.
This method is called after
navigationViewController(_:willRerouteFrom:)and simultaneously with theRouteControllerDidFailToReroutenotification being posted.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:routeStyleLayerWithIdentifier:source:)Default implementationReturns an
MGLStyleLayerthat 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.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:routeCasingStyleLayerWithIdentifier:source:)Default implementationReturns an
MGLStyleLayerthat 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
MGLLineStyleLayerwhose width is greater than that of the style layer returned bynavigationViewController(_:routeStyleLayerWithIdentifier:source:).Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:shapeFor:)Default implementationReturns an
MGLShapethat 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
MGLPolylineFeaturebased onroute’scoordinatesproperty.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:simplifiedShapeFor:)Default implementationReturns an
MGLShapethat 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
MGLPolylineFeatureidentical to the one returned bynavigationViewController(_:shapeFor:).Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:waypointStyleLayerWithIdentifier:source:)Default implementationReturns an
MGLStyleLayerthat marks the location of each destination along the route when there are multiple destinations. The returned layer is added to the map below the layer returned bynavigationViewController(_:waypointSymbolStyleLayerWithIdentifier:source:).If this method is unimplemented, the navigation view controller’s map view marks each destination waypoint with a circle.
Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:waypointSymbolStyleLayerWithIdentifier:source:)Default implementationReturns an
MGLStyleLayerthat places an identifying symbol on each destination along the route when there are multiple destinations. The returned layer is added to the map above the layer returned bynavigationViewController(_:waypointStyleLayerWithIdentifier:source:).If this method is unimplemented, the navigation view controller’s map view labels each destination waypoint with a number, starting with 1 at the first destination, 2 at the second destination, and so on.
Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:shapeFor:legIndex:)Default implementationReturns an
MGLShapethat 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:).Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:didSelect:)Default implementationCalled when the user taps to select a route on the navigation view controller’s map view.
Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:mapViewUserAnchorPoint:)Default implementationReturns the center point of the user course view in screen coordinates relative to the map view.
Default Implementation
-
navigationViewController(_:shouldDiscard:)Default implementationAllows 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.isQualifiedproperty.Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:roadNameAt:)Default implementationCalled 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.
Note
This delegate method includes a default implementation that prints a warning to the console when this method is called. SeeUnimplementedLoggingfor details.Default Implementation
-
navigationViewController(_:imageFor:)Extension method -
navigationViewController(_:viewFor:)Extension method
Install in Dash
NavigationViewControllerDelegate Protocol Reference