RouteStep
open class RouteStep : Codable
extension RouteStep: Equatable
extension RouteStep: CustomStringConvertible
A RouteStep
object represents a single distinct maneuver along a route and the approach to the next maneuver. The route step object corresponds to a single instruction the user must follow to complete a portion of the route. For example, a step might require the user to turn then follow a road.
You do not create instances of this class directly. Instead, you receive route step objects as part of route objects when you request directions using the Directions.calculate(_:completionHandler:)
method, setting the includesSteps
option to true
in the RouteOptions
object that you pass into that method.
-
init(transportType:maneuverLocation:maneuverType:maneuverDirection:instructions:initialHeading:finalHeading:drivingSide:exitCodes:exitNames:phoneticExitNames:distance:expectedTravelTime:typicalTravelTime:names:phoneticNames:codes:destinationCodes:destinations:intersections:speedLimitSignStandard:speedLimitUnit:instructionsSpokenAlongStep:instructionsDisplayedAlongStep:administrativeAreaContainerByIntersection:segmentIndicesByIntersection:)
Initializes a step.
Declaration
Swift
public init(transportType: TransportType, maneuverLocation: Turf.LocationCoordinate2D, maneuverType: ManeuverType, maneuverDirection: ManeuverDirection? = nil, instructions: String, initialHeading: Turf.LocationDirection? = nil, finalHeading: Turf.LocationDirection? = nil, drivingSide: DrivingSide, exitCodes: [String]? = nil, exitNames: [String]? = nil, phoneticExitNames: [String]? = nil, distance: Turf.LocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil, names: [String]? = nil, phoneticNames: [String]? = nil, codes: [String]? = nil, destinationCodes: [String]? = nil, destinations: [String]? = nil, intersections: [Intersection]? = nil, speedLimitSignStandard: SignStandard? = nil, speedLimitUnit: UnitSpeed? = nil, instructionsSpokenAlongStep: [SpokenInstruction]? = nil, instructionsDisplayedAlongStep: [VisualInstructionBanner]? = nil, administrativeAreaContainerByIntersection: [Int?]? = nil, segmentIndicesByIntersection: [Int?]? = nil)
Parameters
transportType
The mode of transportation used for the step.
maneuverLocation
The location of the maneuver at the beginning of this step.
maneuverType
The type of maneuver required for beginning this step.
maneuverDirection
Additional directional information to clarify the maneuver type.
instructions
A string with instructions explaining how to perform the step’s maneuver.
initialHeading
The user’s heading immediately before performing the maneuver.
finalHeading
The user’s heading immediately after performing the maneuver.
drivingSide
Indicates what side of a bidirectional road the driver must be driving on. Also referred to as the rule of the road.
exitCodes
Any exit numbers assigned to the highway exit at the maneuver.
exitNames
The names of the roundabout exit.
phoneticExitNames
A phonetic or phonemic transcription indicating how to pronounce the names in the
exitNames
property.distance
The step’s distance, measured in meters.
expectedTravelTime
The step’s expected travel time, measured in seconds.
typicalTravelTime
The step’s typical travel time, measured in seconds.
names
The names of the road or path leading from this step’s maneuver to the next step’s maneuver.
phoneticNames
A phonetic or phonemic transcription indicating how to pronounce the names in the
names
property.codes
Any route reference codes assigned to the road or path leading from this step’s maneuver to the next step’s maneuver.
destinationCodes
Any route reference codes that appear on guide signage for the road leading from this step’s maneuver to the next step’s maneuver.
destinations
Destinations, such as control cities, that appear on guide signage for the road leading from this step’s maneuver to the next step’s maneuver.
intersections
An array of intersections along the step.
speedLimitSignStandard
The sign design standard used for speed limit signs along the step.
speedLimitUnit
The unit of speed limits on speed limit signs along the step.
instructionsSpokenAlongStep
Instructions about the next step’s maneuver, optimized for speech synthesis.
instructionsDisplayedAlongStep
Instructions about the next step’s maneuver, optimized for display in real time.
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
Declaration
Swift
public required convenience init(from decoder: Decoder) throws
-
The path of the route step from the location of the maneuver to the location of the next step’s maneuver.
The value of this property may be
nil
, for example when the maneuver type isarrive
.Using the Mapbox Maps SDK for iOS or Mapbox Maps SDK for macOS, you can create an
MGLPolyline
object using theLineString.coordinates
property to display a portion of a route on anMGLMapView
.Declaration
Swift
public var shape: LineString?
-
The mode of transportation used for the step.
This step may use a different mode of transportation than the overall route.
Declaration
Swift
public let transportType: TransportType
-
The location of the maneuver at the beginning of this step.
Declaration
Swift
public let maneuverLocation: Turf.LocationCoordinate2D
-
The type of maneuver required for beginning this step.
Declaration
Swift
public let maneuverType: ManeuverType
-
Additional directional information to clarify the maneuver type.
Declaration
Swift
public let maneuverDirection: ManeuverDirection?
-
A string with instructions explaining how to perform the step’s maneuver.
You can display this string or read it aloud to the user. The string does not include the distance to or from the maneuver. For instructions optimized for real-time delivery during turn-by-turn navigation, set the
RouteOptions.includesSpokenInstructions
option and use theinstructionsSpokenAlongStep
property. If you need customized instructions, you can construct them yourself from the step’s other properties or use OSRM Text Instructions.Note
If you use the MapboxDirections framework with the Mapbox Directions API, this property is formatted and localized for display to the user. If you use OSRM directly, this property contains a basic string that only includes the maneuver type and direction. Use OSRM Text Instructions to construct a complete, localized instruction string for display.Declaration
Swift
public let instructions: String
-
The user’s heading immediately before performing the maneuver.
Declaration
Swift
public let initialHeading: Turf.LocationDirection?
-
The user’s heading immediately after performing the maneuver.
The value of this property may differ from the user’s heading after traveling along the road past the maneuver.
Declaration
Swift
public let finalHeading: Turf.LocationDirection?
-
Indicates what side of a bidirectional road the driver must be driving on. Also referred to as the rule of the road.
Declaration
Swift
public let drivingSide: DrivingSide
-
The number of exits from the previous maneuver up to and including this step’s maneuver.
If the maneuver takes place on a surface street, this property counts intersections. The number of intersections does not necessarily correspond to the number of blocks. If the maneuver takes place on a grade-separated highway (freeway or motorway), this property counts highway exits but not highway entrances. If the maneuver is a roundabout maneuver, the exit index is the number of exits from the approach to the recommended outlet. For the signposted exit numbers associated with a highway exit, use the
exitCodes
property.In some cases, the number of exits leading to a maneuver may be more useful to the user than the distance to the maneuver.
Declaration
Swift
open var exitIndex: Int?
-
Any exit numbers assigned to the highway exit at the maneuver.
This property is only set when the
maneuverType
isManeuverType.takeOffRamp
. For the number of exits from the previous maneuver, regardless of the highway’s exit numbering scheme, use theexitIndex
property. For the route reference codes associated with the connecting road, use thedestinationCodes
property. For the names associated with a roundabout exit, use theexitNames
property.An exit number is an alphanumeric identifier posted at or ahead of a highway off-ramp. Exit numbers may increase or decrease sequentially along a road, or they may correspond to distances from either end of the road. An alphabetic suffix may appear when multiple exits are located in the same interchange. If multiple exits are combined into a single exit, the step may have multiple exit codes.
Declaration
Swift
public let exitCodes: [String]?
-
The names of the roundabout exit.
This property is only set for roundabout (traffic circle or rotary) maneuvers. For the signposted names associated with a highway exit, use the
destinations
property. For the signposted exit numbers, use theexitCodes
property.If you display a name to the user, you may need to abbreviate common words like “East” or “Boulevard” to ensure that it fits in the allotted space.
Declaration
Swift
public let exitNames: [String]?
-
A phonetic or phonemic transcription indicating how to pronounce the names in the
exitNames
property.This property is only set for roundabout (traffic circle or rotary) maneuvers.
The transcription is written in the International Phonetic Alphabet.
Declaration
Swift
public let phoneticExitNames: [String]?
-
The step’s distance, measured in meters.
The value of this property accounts for the distance that the user must travel to go from this step’s maneuver location to the next step’s maneuver location. It is not the sum of the direct distances between the route’s waypoints, nor should you assume that the user would travel along this distance at a fixed speed.
Declaration
Swift
public let distance: Turf.LocationDistance
-
The step’s expected travel time, measured in seconds.
The value of this property reflects the time it takes to go from this step’s maneuver location to the next step’s maneuver location. If the route was calculated using the
ProfileIdentifier.automobileAvoidingTraffic
profile, this property reflects current traffic conditions at the time of the request, not necessarily the traffic conditions at the time the user would begin this step. For other profiles, this property reflects travel time under ideal conditions and does not account for traffic congestion. If the step makes use of a ferry or train, the actual travel time may additionally be subject to the schedules of those services.Do not assume that the user would travel along the step at a fixed speed. For the expected travel time on each individual segment along the leg, specify the
AttributeOptions.expectedTravelTime
option and use theRouteLeg.expectedSegmentTravelTimes
property.Declaration
Swift
open var expectedTravelTime: TimeInterval
-
The step’s typical travel time, measured in seconds.
The value of this property reflects the typical time it takes to go from this step’s maneuver location to the next step’s maneuver location. This property is available when using the
ProfileIdentifier.automobileAvoidingTraffic
profile. This property reflects typical traffic conditions at the time of the request, not necessarily the typical traffic conditions at the time the user would begin this step. If the step makes use of a ferry, the typical travel time may additionally be subject to the schedule of this service.Do not assume that the user would travel along the step at a fixed speed.
Declaration
Swift
open var typicalTravelTime: TimeInterval?
-
The names of the road or path leading from this step’s maneuver to the next step’s maneuver.
If the maneuver is a turning maneuver, the step’s names are the name of the road or path onto which the user turns. If you display a name to the user, you may need to abbreviate common words like “East” or “Boulevard” to ensure that it fits in the allotted space.
If the maneuver is a roundabout maneuver, the outlet to take is named in the
exitNames
property; thenames
property is only set for large roundabouts that have their own names.Declaration
Swift
public let names: [String]?
-
A phonetic or phonemic transcription indicating how to pronounce the names in the
names
property.The transcription is written in the International Phonetic Alphabet.
If the maneuver traverses a large, named roundabout, the
exitPronunciationHints
property contains a hint about how to pronounce the names of the outlet to take.Declaration
Swift
public let phoneticNames: [String]?
-
Any route reference codes assigned to the road or path leading from this step’s maneuver to the next step’s maneuver.
A route reference code commonly consists of an alphabetic network code, a space or hyphen, and a route number. You should not assume that the network code is globally unique: for example, a network code of “NH” may indicate a “National Highway” or “New Hampshire”. Moreover, a route number may not even uniquely identify a route within a given network.
If a highway ramp is part of a numbered route, its reference code is contained in this property. On the other hand, guide signage for a highway ramp usually indicates route reference codes of the adjoining road; use the
destinationCodes
property for those route reference codes.Declaration
Swift
public let codes: [String]?
-
Any route reference codes that appear on guide signage for the road leading from this step’s maneuver to the next step’s maneuver.
This property is typically available in steps leading to or from a freeway or expressway. This property contains route reference codes associated with a road later in the route. If a highway ramp is itself part of a numbered route, its reference code is contained in the
codes
property. For the signposted exit numbers associated with a highway exit, use theexitCodes
property.A route reference code commonly consists of an alphabetic network code, a space or hyphen, and a route number. You should not assume that the network code is globally unique: for example, a network code of “NH” may indicate a “National Highway” or “New Hampshire”. Moreover, a route number may not even uniquely identify a route within a given network. A destination code for a divided road is often suffixed with the cardinal direction of travel, for example “I 80 East”.
Declaration
Swift
public let destinationCodes: [String]?
-
Destinations, such as control cities, that appear on guide signage for the road leading from this step’s maneuver to the next step’s maneuver.
This property is typically available in steps leading to or from a freeway or expressway.
Declaration
Swift
public let destinations: [String]?
-
An array of intersections along the step.
Each item in the array corresponds to a cross street, starting with the intersection at the maneuver location indicated by the coordinates property and continuing with each cross street along the step.
Declaration
Swift
public let intersections: [Intersection]?
-
Each intersection’s administrative region index.
This property is set to
nil
if theintersections
property isnil
. An individual array element may benil
if the correspondingIntersection
instance has no administrative region assigned.Declaration
Swift
public let administrativeAreaContainerByIntersection: [Int?]?
-
Segments indices for each
Intersection
along the step.The indices are arranged in the same order as the items of
intersections
. This property isnil
ifintersections
isnil
. An individual item may benil
if the corresponding JSON-formatted intersection object has nogeometry_index
property.Declaration
Swift
public let segmentIndicesByIntersection: [Int?]?
-
The sign design standard used for speed limit signs along the step.
This standard affects how corresponding speed limits in the
RouteLeg.segmentMaximumSpeedLimits
property should be displayed.Declaration
Swift
public let speedLimitSignStandard: SignStandard?
-
The unit of speed limits on speed limit signs along the step.
This standard affects how corresponding speed limits in the
RouteLeg.segmentMaximumSpeedLimits
property should be displayed.Declaration
Swift
public let speedLimitUnit: UnitSpeed?
-
Instructions about the next step’s maneuver, optimized for speech synthesis.
As the user traverses this step, you can give them advance notice of the upcoming maneuver by reading aloud each item in this array in order as the user reaches the specified distances along this step. The text of the spoken instructions refers to the details in the next step, but the distances are measured from the beginning of this step.
This property is non-
nil
if theRouteOptions.includesSpokenInstructions
option is set totrue
. For instructions designed for display, use theinstructions
property.Declaration
Swift
public let instructionsSpokenAlongStep: [SpokenInstruction]?
-
Instructions about the next step’s maneuver, optimized for display in real time.
As the user traverses this step, you can give them advance notice of the upcoming maneuver by displaying each item in this array in order as the user reaches the specified distances along this step. The text and images of the visual instructions refer to the details in the next step, but the distances are measured from the beginning of this step.
This property is non-
nil
if theRouteOptions.includesVisualInstructions
option is set totrue
. For instructions designed for speech synthesis, use theinstructionsSpokenAlongStep
property. For instructions designed for display in a static list, use theinstructions
property.Declaration
Swift
public let instructionsDisplayedAlongStep: [VisualInstructionBanner]?
-
Declaration
Swift
public static func == (lhs: RouteStep, rhs: RouteStep) -> Bool
-
Declaration
Swift
public var description: String { get }