iOS Developer Library

Developer

MKRoute Class Reference

Options
Deployment Target:

On This Page
Language:

MKRoute

Inheritance


Conforms To


Import Statement


Swift

import MapKit

Objective-C

@import MapKit;

Availability


Available in iOS 7.0 and later.

The MKRoute class defines a single route that the user can follow between a requested start and end point. The route object defines the geometry for the route and includes information you can display to the user in association with that route, such as the name of the route, its distance, and the expected travel time.

You do not create instances of this class directly. Instead, you receive route objects when you request directions from the Maps app. For more information about requesting directions, see MKDirections Class Reference.

  • polyline polyline Property

    The detailed route geometry. (read-only)

    Declaration

    Swift

    var polyline: MKPolyline! { get }

    Objective-C

    @property(nonatomic, readonly) MKPolyline *polyline

    Discussion

    The polyline object in this property reflects the complete path of the route, including all of its steps. You can use the polyline object as an overlay in a map view.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • steps steps Property

    The array of steps that comprise the overall route. (read-only)

    Declaration

    Swift

    var steps: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *steps

    Discussion

    The array contains one or more MKRouteStep objects representing distinct portions of the route. Each step corresponds to a single direction that must be followed along the route.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • name name Property

    The name assigned to the route. (read-only)

    Declaration

    Swift

    var name: String! { get }

    Objective-C

    @property(nonatomic, readonly) NSString *name

    Discussion

    The string in this property is localized according to the user’s language preferences. You can display this string to the user from your app’s user interface so that the user can distinguish one route from another.

    The string itself describes the route using one of the route’s significant features. For example, a route that uses a major highway for a significant portion of the route might use that highway for its name.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • An array of advisory notice strings for the route. (read-only)

    Declaration

    Swift

    var advisoryNotices: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *advisoryNotices

    Discussion

    This property contains an array of NSString objects. Each string is localized according to the user’s language preferences. The strings contain additional information that is important for the user to know about the route. For example, a string might note that a portion of the route is closed during the winter or after big storms.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • distance distance Property

    The route distance in meters. (read-only)

    Declaration

    Swift

    var distance: CLLocationDistance { get }

    Objective-C

    @property(nonatomic, readonly) CLLocationDistance distance

    Discussion

    This property reflects the distance that the user covers while traversing the path of the route. It is not a direct distance between the start and end points of the route.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • The expected travel time in seconds. (read-only)

    Declaration

    Swift

    var expectedTravelTime: NSTimeInterval { get }

    Objective-C

    @property(nonatomic, readonly) NSTimeInterval expectedTravelTime

    Discussion

    This expected travel time reflects the time it takes to traverse the route under ideal conditions. The actual amount of time may vary based on conditions.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • The overall route transport type. (read-only)

    Declaration

    Swift

    var transportType: MKDirectionsTransportType { get }

    Objective-C

    @property(nonatomic, readonly) MKDirectionsTransportType transportType

    Discussion

    This property reflects the primary transport type used for the route. Individual steps of the route might use different transport types.

    Import Statement

    Objective-C

    @import MapKit;

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.