NavigationMapViewDelegate

public protocol NavigationMapViewDelegate : AnyObject, UnimplementedLogging

The NavigationMapViewDelegate provides methods for configuring the NavigationMapView, as well as responding to events triggered by the NavigationMapView.

  • Asks the receiver to return an MGLStyleLayer for the main route line, 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, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

    Parameters

    mapView

    The NavigationMapView.

    identifier

    The style identifier.

    source

    The source containing the route data that this method would style.

    Return Value

    An MGLStyleLayer that is applied to the main route line.

  • Asks the receiver to return an MGLStyleLayer for the casing layer that surrounds main route line, 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, mainRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

    Parameters

    mapView

    The NavigationMapView.

    identifier

    The style identifier.

    source

    The source containing the route data that this method would style.

    Return Value

    An MGLStyleLayer that is applied as a casing around the main route line.

  • Asks the receiver to return an MGLStyleLayer for the alternative route lines, 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, alternativeRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

    Parameters

    mapView

    The NavigationMapView.

    identifier

    The style identifier.

    source

    The source containing the route data that this method would style.

    Return Value

    An MGLStyleLayer that is applied to alternative routes.

  • Asks the receiver to return an MGLStyleLayer for the casing layer that surrounds alternative route lines, 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, alternativeRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

    Parameters

    mapView

    The NavigationMapView.

    identifier

    The style identifier.

    source

    The source containing the route data that this method would style.

    Return Value

    An MGLStyleLayer that is applied as a casing around alternative route lines.

  • Asks 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.

  • Asks 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(_:didSelect:) Default implementation

    Tells 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 implementation

    Asks the receiver to return an MGLShape that describes the geometry of the route.

    Resulting MGLShape will then be styled using NavigationMapView.navigationMapView(_: mainRouteStyleLayerWithIdentifier: source:) provided style or a default congestion style if above delegate method was not implemented. In latter case, consider modifing your custom MGLShape attributes to have ‘isAlternateRoute’ key set to ‘false’. Otherwise style predicate condition will filter out the shape.

    Note

    The returned value represents the route in full detail. For example, individual MGLPolyline objects in an MGLShapeCollectionFeature object can represent traffic congestion segments. For improved performance, you should also implement navigationMapView(_: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 alternative routes.

    Return Value

    Optionally, a MGLShape that defines the shape of the route, or nil to use default behavior.

  • Asks the receiver to return an MGLShape that describes the geometry of the route at lower zoomlevels.

    Resulting MGLShape will then be styled using NavigationMapView.navigationMapView(_: mainRouteCasingStyleLayerWithIdentifier: source:) provided style or a default style if above delegate method was not implemented. In latter case, consider modifing your custom MGLShape attributes to have ‘isAlternateRoute’ key set to ‘false’. Otherwise style predicate condition will filter out the shape.

    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, or nil to use default behavior.

  • Asks 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, or nil to use default behavior.

  • navigationMapViewUserAnchorPoint(_:) Default implementation

    Asks 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.