NavigationMapViewDelegate
public protocol NavigationMapViewDelegate : AnyObject, UnimplementedLogging
The NavigationMapViewDelegate
provides methods for configuring the NavigationMapView, as well as responding to events triggered by the NavigationMapView.
-
navigationMapView(_:routeStyleLayerWithIdentifier:source:)
Default implementationAsks the receiver to return an MGLStyleLayer for routes, given an identifier and source. This method is invoked when the map view loads and any time routes are added.
Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, routeStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
Parameters
mapView
The NavigationMapView.
identifier
The style identifier.
source
The Layer source containing the route data that this method would style.
Return Value
An MGLStyleLayer that the map applies to all routes.
-
navigationMapView(_:waypointStyleLayerWithIdentifier:source:)
Default implementationAsks the receiver to return an MGLStyleLayer for waypoints, given an identifier and source. This method is invoked when the map view loads and any time waypoints are added.
Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, waypointStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
Parameters
mapView
The NavigationMapView.
identifier
The style identifier.
source
The Layer source containing the waypoint data that this method would style.
Return Value
An MGLStyleLayer that the map applies to all waypoints.
-
navigationMapView(_:waypointSymbolStyleLayerWithIdentifier:source:)
Default implementationAsks the receiver to return an MGLStyleLayer for waypoint symbols, given an identifier and source. This method is invoked when the map view loads and any time waypoints are added.
Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, waypointSymbolStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
Parameters
mapView
The NavigationMapView.
identifier
The style identifier.
source
The Layer source containing the waypoint data that this method would style.
Return Value
An MGLStyleLayer that the map applies to all waypoint symbols.
-
navigationMapView(_:routeCasingStyleLayerWithIdentifier:source:)
Default implementationAsks the receiver to return an MGLStyleLayer for route casings, given an identifier and source. This method is invoked when the map view loads and anytime routes are added.
Note
Specify a casing to ensure good contrast between the route line and the underlying map layers.Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, routeCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
Parameters
mapView
The NavigationMapView.
identifier
The style identifier.
source
The Layer source containing the route data that this method would style.
Return Value
An MGLStyleLayer that the map applies to the route.
-
navigationMapView(_:didSelect:)
Default implementationTells the receiver that the user has selected a route by interacting with the map view.
Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route)
Parameters
mapView
The NavigationMapView.
route
The route that was selected.
-
Tells the receiver that a waypoint was selected.
Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, didSelect waypoint: Waypoint)
Parameters
mapView
The NavigationMapView.
waypoint
The waypoint that was selected.
-
navigationMapView(_:shapeFor:)
Default implementationAsks the receiver to return an MGLShape that describes the geometry of the route.
Note
The returned value represents the route in full detail. For example, individualMGLPolyline
objects in anMGLShapeCollectionFeature
object can represent traffic congestion segments. For improved performance, you should also implementnavigationMapView(_:simplifiedShapeFor:)
, which defines the overall route as a single feature.Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, shapeFor routes: [Route]) -> MGLShape?
Parameters
mapView
The NavigationMapView.
routes
The routes that the sender is asking about. The first route will always be rendered as the main route, while all subsequent routes will be rendered as alternate routes.
Return Value
Optionally, a
MGLShape
that defines the shape of the route, ornil
to use default behavior. -
navigationMapView(_:simplifiedShapeFor:)
Default implementationAsks the receiver to return an MGLShape that describes the geometry of the route at lower zoomlevels.
Note
The returned value represents the simplfied route. It is designed to be used with `navigationMapView(_:shapeFor:), and if used without its parent method, can cause unexpected behavior.Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape?
Parameters
mapView
The NavigationMapView.
route
The route that the sender is asking about.
Return Value
Optionally, a
MGLShape
that defines the shape of the route at lower zoomlevels, ornil
to use default behavior. -
navigationMapView(_:shapeFor:legIndex:)
Default implementationAsks the receiver to return an MGLShape that describes the geometry of the waypoint.
Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapView(_ mapView: NavigationMapView, shapeFor waypoints: [Waypoint], legIndex: Int) -> MGLShape?
Parameters
mapView
The NavigationMapView.
waypoints
The waypoints to be displayed on the map.
Return Value
Optionally, a
MGLShape
that defines the shape of the waypoint, ornil
to use default behavior. -
navigationMapViewUserAnchorPoint(_:)
Default implementationAsks the receiver to return a CGPoint to serve as the anchor for the user icon.
Important
The return value should be returned in the normal UIKit coordinate-space, NOT CoreAnimation’s unit coordinate-space.Default Implementation
UnimplementedLogging
prints a warning to standard output the first time this method is called.Declaration
Swift
func navigationMapViewUserAnchorPoint(_ mapView: NavigationMapView) -> CGPoint
Parameters
mapView
The NavigationMapView.
Return Value
A CGPoint (in regular coordinate-space) that represents the point on-screen where the user location icon should be drawn.