NavigationMapViewDelegate

@objc(MBNavigationMapViewDelegate)
public protocol NavigationMapViewDelegate : AnyObject

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 routes, given an identifier and source. This method is invoked when the map view loads and any time routes are added.

    Declaration

    Swift

    @objc
    optional 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.

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

    Declaration

    Swift

    @objc
    optional 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.

    Declaration

    Swift

    @objc
    optional 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.

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

    Declaration

    Swift

    @objc
    optional 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.

  • Tells the receiver that the user has selected a route by interacting with the map view.

    Declaration

    Swift

    @objc(navigationMapView:didSelectRoute:)
    optional 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

    @objc(navigationMapView:didSelectWaypoint:)
    optional func navigationMapView(_ mapView: NavigationMapView, didSelect waypoint: Waypoint)

    Parameters

    mapView

    The NavigationMapView.

    waypoint

    The waypoint that was selected.

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

    Declaration

    Swift

    @objc(navigationMapView:shapeForRoutes:)
    optional 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, or nil to use default behavior.

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

    Declaration

    Swift

    @objc(navigationMapView:simplifiedShapeForRoute:)
    optional 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.

    Declaration

    Swift

    @objc(navigationMapView:shapeForWaypoints:legIndex:)
    optional 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.

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

    Declaration

    Swift

    @objc(navigationMapViewUserAnchorPoint:)
    optional 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.