Class

MKDirectionsRequest

The start and end points of a route, along with the planned mode of transportation.

Overview

You use an MKDirectionsRequest object when requesting or providing directions. If your app provides directions, use this class to decode the URL sent to you by Maps. If you need to request directions from Apple, pass an instance of this class to an MKDirections object. For example, an app that provides subway directions might request walking directions to and from relevant subway stations.

For apps that provide directions, you receive direction-related URLs in your app delegate’s application(_:open:sourceApplication:annotation:) method. Upon receiving a URL, call 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.

Topics

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

struct MKDirectionsTransportType

Constants that specify the type of conveyance to be used.

Relationships

Inherits From

Conforms To

See Also

Directions

class MKMapItem

A point of interest on the map.

class MKDirections

A utility object that computes directions and travel-time information based on the route information you provide.

class MKDirectionsResponse

The route information returned by Apple servers in response to one of your requests for directions.

class MKETAResponse

The travel-time information returned by Apple servers.

class MKRoute

A single route between a requested start and end point.

class MKRouteStep

One portion of an overall route.