DirectionsOptions
open class DirectionsOptions : Codable
extension DirectionsOptions: Equatable
Options for calculating results from the Mapbox Directions service.
You do not create instances of this class directly. Instead, create instances of MatchOptions
or RouteOptions
.
-
Initializes an options object for routes between the given waypoints and an optional profile identifier.
Do not call
DirectionsOptions(waypoints:profileIdentifier:)
directly; instead call the corresponding initializer ofRouteOptions
orMatchOptions
.Declaration
Swift
required public init(waypoints: [Waypoint], profileIdentifier: ProfileIdentifier? = nil, queryItems: [URLQueryItem]? = nil)
Parameters
waypoints
An array of
Waypoint
objects representing locations that the route should visit in chronological order. The array should contain at least two waypoints (the source and destination) and at most 25 waypoints. (Some profiles, such asProfileIdentifier.automobileAvoidingTraffic
, may have lower limits.)profileIdentifier
A string specifying the primary mode of transportation for the routes.
ProfileIdentifier.automobile
is used by default.queryItems
URL query items to be parsed and applied as configuration to the resulting options.
-
Creates new options object by deserializing given
url
Initialization fails if it is unable to extract
waypoints
list andprofileIdentifier
. If other properties are failed to decode - it will just skip them.Declaration
Swift
public convenience init?(url: URL)
Parameters
url
An URL, used to make a route request.
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
Declaration
Swift
public required init(from decoder: Decoder) throws
-
An array of
Waypoint
objects representing locations that the route should visit in chronological order.A waypoint object indicates a location to visit, as well as an optional heading from which to approach the location.
The array should contain at least two waypoints (the source and destination) and at most 25 waypoints.
Declaration
Swift
open var waypoints: [Waypoint]
-
A string specifying the primary mode of transportation for the routes.
The default value of this property is
ProfileIdentifier.automobile
, which specifies driving directions.Declaration
Swift
open var profileIdentifier: ProfileIdentifier
-
A Boolean value indicating whether
RouteStep
objects should be included in the response.If the value of this property is
true
, the returned route contains turn-by-turn instructions. Each returnedRoute
object contains one or moreRouteLeg
object that in turn contains one or moreRouteStep
objects. On the other hand, if the value of this property isfalse
, theRouteLeg
objects contain noRouteStep
objects.If you only want to know the distance or estimated travel time to a destination, set this property to
false
to minimize the size of the response and the time it takes to calculate the response. If you need to display turn-by-turn instructions, set this property totrue
.The default value of this property is
false
.Declaration
Swift
open var includesSteps: Bool
-
Format of the data from which the shapes of the returned route and its steps are derived.
This property has no effect on the returned shape objects, although the choice of format can significantly affect the size of the underlying HTTP response.
The default value of this property is
polyline
.Declaration
Swift
open var shapeFormat: RouteShapeFormat
-
Resolution of the shape of the returned route.
This property has no effect on the shape of the returned route’s steps.
The default value of this property is
low
, specifying a low-resolution route shape.Declaration
Swift
open var routeShapeResolution: RouteShapeResolution
-
AttributeOptions for the route. Any combination of
AttributeOptions
can be specified.By default, no attribute options are specified. It is recommended that
routeShapeResolution
be set to.full
.Declaration
Swift
open var attributeOptions: AttributeOptions
-
The locale in which the route’s instructions are written.
If you use the MapboxDirections framework with the Mapbox Directions API or Map Matching API, this property affects the sentence contained within the
RouteStep.instructions
property, but it does not affect any road names contained in that property or other properties such asRouteStep.name
.The Directions API can provide instructions in a number of languages. Set this property to
Bundle.main.preferredLocalizations.first
orLocale.autoupdatingCurrent
to match the application’s language or the system language, respectively.By default, this property is set to the current system locale.
Declaration
Swift
open var locale: Locale { get set }
-
A Boolean value indicating whether each route step includes an array of
SpokenInstructions
.If this option is set to true, the
RouteStep.instructionsSpokenAlongStep
property is set to an array ofSpokenInstructions
.Declaration
Swift
open var includesSpokenInstructions: Bool
-
The measurement system used in spoken instructions included in route steps.
If the
includesSpokenInstructions
property is set totrue
, this property determines the units used for measuring the distance remaining until an upcoming maneuver. If theincludesSpokenInstructions
property is set tofalse
, this property has no effect.You should choose a measurement system appropriate for the current region. You can also allow the user to indicate their preferred measurement system via a setting.
Declaration
Swift
open var distanceMeasurementSystem: MeasurementSystem
-
If true, each
RouteStep
will contain the propertyvisualInstructionsAlongStep
.visualInstructionsAlongStep
contains an array ofVisualInstruction
objects used for visually conveying information about a givenRouteStep
.Declaration
Swift
open var includesVisualInstructions: Bool
-
The time immediately before a
Directions
object fetched this result.If you manually start fetching a task returned by
Directions.url(forCalculating:)
, this property is set tonil
; use theURLSessionTaskTransactionMetrics.fetchStartDate
property instead. This property may also be set tonil
if you create this result from a JSON object or encoded object.This property does not persist after encoding and decoding.
Declaration
Swift
open var fetchStartDate: Date?
-
An array of URL query items (parameters) to include in an HTTP request.
The query items are included in the URL of a GET request or the body of a POST request.
Declaration
Swift
open var urlQueryItems: [URLQueryItem] { get }
-
Declaration
Swift
public static func == (lhs: DirectionsOptions, rhs: DirectionsOptions) -> Bool