MKDirectionsRequest Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/MapKit.framework
Availability
Available in iOS 6.0 and later.
Companion guide
Declared in
MKDirectionsRequest.h

Overview

The MKDirectionsRequest class is used by apps that are capable of displaying turn-based directions to the user. When the Maps app sends a directions-related URL to your app, you use this class to decode the URL contents and access the routing data. You then use that data to compute the actual route and display the results to the user.

Upon receiving a URL in your app delegate’s application:openURL:sourceApplication:annotation: method, you can use the isDirectionsRequestURL: 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.

To provide routing directions, apps must include special keys in their Info.plist file and be able to handle URLs sent to it by the Maps app. These keys indicate a special URL type that your app must be prepared to handle. For information about how to implement this support, see Location Awareness Programming Guide.

Tasks

Creating a Directions Request Object

Accessing the Start and End Points

Properties

destination

The end point for routing directions. (read-only)

@property (nonatomic, readonly) MKMapItem *destination
Availability
  • Available in iOS 6.0 and later.
Declared In
MKDirectionsRequest.h

source

The starting point for routing directions. (read-only)

@property (nonatomic, readonly) MKMapItem *source
Availability
  • Available in iOS 6.0 and later.
Declared In
MKDirectionsRequest.h

Class Methods

isDirectionsRequestURL:

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

+ (BOOL)isDirectionsRequestURL:(NSURL *)url
Parameters
url

The URL provided to your app.

Return Value

YES if the URL contains a directions request that your app should display to the user or NO if it does not.

Availability
  • Available in iOS 6.0 and later.
Declared In
MKDirectionsRequest.h

Instance Methods

initWithContentsOfURL:

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

- (id)initWithContentsOfURL:(NSURL *)url
Parameters
url

The URL provided to your app.

Return Value

An initialized directions request object.

Discussion

You should use the isDirectionsRequestURL: method to verify that the specified URL is of the correct format before calling this method to initialize the object.

Availability
  • Available in iOS 6.0 and later.
Declared In
MKDirectionsRequest.h

Did this document help you? Yes It's good, but... Not helpful...