Class

MKDirections.Request

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

Declaration

class Request : NSObject

Overview

You use an MKDirections.Request 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) -> Bool

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.

Launch Options

let MKLaunchOptionsCameraKey: String

The virtual camera to use for viewing the map.

let MKLaunchOptionsDirectionsModeDefault: String

Directions that match the user’s preferred transportation type.

let MKLaunchOptionsDirectionsModeDriving: String

Driving directions between the specified start and end points.

let MKLaunchOptionsDirectionsModeTransit: String

Public transit directions between the specified start and end points.

let MKLaunchOptionsDirectionsModeWalking: String

Walking directions between the specified start and end points.

let MKLaunchOptionsMapCenterKey: String

The coordinate value on which to center the map.

let MKLaunchOptionsMapSpanKey: String

The amount of the map to display.

let MKLaunchOptionsMapTypeKey: String

The type of map (standard, satellite, or hybrid) to display.

let MKLaunchOptionsShowsTrafficKey: String

A Boolean value indicating whether to display traffic information.

Relationships

Inherits From

Conforms To

See Also

Creating a Directions Object

init(request: MKDirections.Request)

Initializes and returns a directions object using the specified request.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software