open class RouteLeg: NSObject, NSSecureCoding
RouteLeg object defines a single leg of a route between two waypoints. If the overall route has only two waypoints, it has a single
RouteLeg object that covers the entire route. The route leg object includes information about the leg, such as its name, distance, and expected travel time. Depending on the criteria used to calculate the route, the route leg object may also include detailed turn-by-turn instructions.
You do not create instances of this class directly. Instead, you receive route leg objects as part of route objects when you request directions using the
Initializes a new route leg object with the given JSON dictionary representation and waypoints.
Normally, you do not create instances of this class directly. Instead, you receive route leg objects as part of route objects when you request directions using the
A JSON dictionary representation of a route leg object as returnd by the Mapbox Directions API.
The waypoint at the beginning of the leg.
The waypoint at the end of the leg.
The profile identifier used to request the routes.
An array of one or more
RouteStepobjects representing the steps for traversing this leg of the route.
Each route step object corresponds to a distinct maneuver and the approach to the next maneuver.
This array is empty if the
includesStepsproperty of the original
RouteOptionsobject is set to
open let steps: [RouteStep]
An array containing the expected travel time (measured in seconds) between each coordinate in the route leg geometry.
These values are dynamic, accounting for any conditions that may change along a segment, such as traffic congestion if the profile identifier is set to
open let expectedSegmentTravelTimes: [TimeInterval]?
An array containing the expected average speed (measured in meters per second) between each coordinate in the route leg geometry.
These values are dynamic; rather than speed limits, they account for the road’s classification and/or any traffic congestion (if the profile identifier is set to
This property is set if the
open let segmentSpeeds: [CLLocationSpeed]?
An array containing the traffic congestion level along each road segment in the route leg geometry.
Traffic data is available in a number of countries and territories worldwide.
You can color-code a route line according to the congestion level along each segment of the route.
This property is set if the
open let segmentCongestionLevels: [CongestionLevel]?
A name that describes the route leg.
The name describes the leg using the most significant roads or trails along the route leg. You can display this string to the user to help the user can distinguish one route from another based on how the legs of the routes are named.
The leg’s name does not identify the start and end points of the leg. To distinguish one leg from another within the same route, concatenate the
nameproperties of the
open let name: String
The route leg’s distance, measured in meters.
The value of this property accounts for the distance that the user must travel to arrive at the destination from the source. It is not the direct distance between the source and destination, nor should not assume that the user would travel along this distance at a fixed speed.
open let distance: CLLocationDistance
The route leg’s expected travel time, measured in seconds.
The value of this property reflects the time it takes to traverse the route leg under ideal conditions. You should not assume that the user would travel along the route leg at a fixed speed. The actual travel time may vary based on the weather, traffic conditions, road construction, and other variables. If the route leg makes use of a ferry or train, the actual travel time may additionally be subject to the schedules of those services.
open let expectedTravelTime: TimeInterval
A string specifying the primary mode of transportation for the route leg.
The value of this property is
MBDirectionsProfileIdentifierWalking, depending on the
profileIdentifierproperty of the original
RouteOptionsobject. This property reflects the primary mode of transportation used for the route leg. Individual steps along the route leg might use different modes of transportation as necessary.
open let profileIdentifier: MBDirectionsProfileIdentifier