Class

MKDirections

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

Declaration

class MKDirections : NSObject

Overview

You use an MKDirections object to ask the Apple servers to provide walking or driving directions for a route, which you specify using an MKDirections.Request object. After making a request, MapKit delivers the results asynchronously to the completion handler that you provide. You can also get the estimated travel time for the route.

Each MKDirections object handles a single request for directions, although you can cancel and restart that request as needed. You can create multiple instances of this class and process different route requests at the same time, but you should make requests only when you plan to present the corresponding route information to the user. Apps may receive a MKError.Code.loadingThrottled error if too many requests have been made from the current device in too short a time period.

Topics

Creating a Directions Object

init(request: MKDirections.Request)

Initializes and returns a directions object using the specified request.

class MKDirections.Request

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

Getting the Directions

func calculate(completionHandler: MKDirections.DirectionsHandler)

Begins calculating the requested route information asynchronously.

typealias MKDirections.DirectionsHandler

The block to use for processing the requested route information.

class MKDirections.Response

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

Getting the ETA

func calculateETA(completionHandler: MKDirections.ETAHandler)

Begins calculating the requested travel-time information asynchronously.

typealias MKDirections.ETAHandler

The block to use for processing travel-time information.

class MKDirections.ETAResponse

The travel-time information returned by Apple servers.

Managing the Request

func cancel()

Cancels a pending request.

var isCalculating: Bool

A Boolean value indicating whether a request is currently in process.

Relationships

Inherits From

Conforms To

See Also

Directions

class MKMapItem

A point of interest on the map.

class MKDirections.Request

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

class MKDirections.Response

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

class MKDirections.ETAResponse

The travel-time information returned by Apple servers.

class MKRoute

A single route between a requested start and end point.

class MKRoute.Step

One portion of an overall route.