Class

MKDirectionsRequest

The MKDirectionsRequest class is used by apps that work with turn-based directions. When the Maps app sends a directions-related URL to your app, you use this class to decode the URL contents and determine the start and end points of a route. You then use that data to compute the actual route and display the results to the user. For apps that want to supplement their own routing directions, you can also use instances of this class to specify route information that you want from Apple.

Overview

For apps that provide directions, upon receiving a URL in your app delegate’s application(_:open:sourceApplication:annotation:) method, use the isDirectionsRequest(_:) method of this class to determine if the URL is related to routing directions. If it is, create an instance of this class using the provided URL and extract the map items associated with the start and end points. You can then use those points to begin your route planning.

You can use this class to request directions for modes of transportation that your app does not natively handle. For example, an app that provides subway directions might request walking directions to and from relevant subway stations. To request directions, create a new instance of this class and configure it with the new start and end points you need. Then create a MKDirections object and use the methods of that class to initiate the request and process the results.

Symbols

Creating a Directions Request Object

class func isDirectionsRequest(URL)

Returns a Boolean indicating whether the specified URL contains a directions request.

init(contentsOf: URL)

Initializes and returns a directions request object using the specified URL.

Accessing the Start and End Points

var source: MKMapItem?

The starting point for routing directions.

var destination: MKMapItem?

The end point for routing directions

Specifying Transportation Options

var transportType: MKDirectionsTransportType

The type of conveyance to which the directions should apply.

var requestsAlternateRoutes: Bool

A Boolean indicating whether your app wants multiple routes when they are available.

var departureDate: Date?

The departure date for the trip.

var arrivalDate: Date?

The arrival date for the trip.

Constants

MKDirectionsTransportType

Constants that specify the type of conveyance to be used.

Relationships

Inherits From

Conforms To