Route
A Route object defines a single route that the user can follow to visit a series of waypoints in order. The route object includes information about the route, such as its distance and expected travel time. Depending on the criteria used to calculate the route, the route object may also include detailed turn-by-turn instructions.
Typically, you do not create instances of this class directly. Instead, you receive route objects when you request directions using the Directions.calculate(_:completionHandler:) or Directions.calculateRoutes(matching:completionHandler:) method. However, if you use the Directions.url(forCalculating:) method instead, you can use JSONDecoder to convert the HTTP response into a RouteResponse or MapMatchingResponse object and access the RouteResponse.routes or MapMatchingResponse.routes property.
-
Initializes a route.
Declaration
Swift
public override init(legs: [RouteLeg], shape: LineString?, distance: LocationDistance, expectedTravelTime: TimeInterval, typicalTravelTime: TimeInterval? = nil)Parameters
legsThe legs that are traversed in order.
shapeThe roads or paths taken as a contiguous polyline.
distanceThe route’s distance, measured in meters.
expectedTravelTimeThe route’s expected travel time, measured in seconds.
typicalTravelTimeThe route’s typical travel time, measured in seconds.
-
Initializes a route from a decoder.
Precondition
If the decoder is decoding JSON data from an API response, theDecoder.userInfodictionary must contain aRouteOptionsorMatchOptionsobject in theCodingUserInfoKey.optionskey. If it does not, aDirectionsCodingError.missingOptionserror is thrown.Declaration
Swift
public required init(from decoder: Decoder) throwsParameters
decoderThe decoder of JSON-formatted API response data or a previously encoded
Routeobject. -
Declaration
Swift
open override func encode(to encoder: Encoder) throws -
Declaration
Swift
public static func == (lhs: Route, rhs: Route) -> Bool -
Configuration for applying
See moreRouteRefreshSourceupdates to a route.Declaration
Swift
public struct RefreshParameters -
Merges various properties from
refreshedRoutelegs to the reciever.Declaration
Swift
public func refresh(from refreshedRoute: RouteRefreshSource, refreshParameters: RefreshParameters = RefreshParameters())Parameters
refreshedRouteThe route containing leg data to merge into the receiver. If this route contains fewer legs than the receiver, this method skips legs from the beginning of the route to make up the difference, so that merging the data from a one-leg route affects only the last leg of the receiver.
refreshParametersConfiguration about what exactly should be updated and from which geometry position.
-
Merges the attributes of the given route’s legs into the receiver’s legs.
Declaration
Swift
public func refreshLegAttributes(from refreshedRoute: RouteRefreshSource)Parameters
refreshedRouteThe route containing leg attributes to merge into the receiver. If this route contains fewer legs than the receiver, this method skips legs from the beginning of the route to make up the difference, so that merging the attributes from a one-leg route affects only the last leg of the receiver.
-
Merges the attributes of the given route’s legs into the receiver’s legs.
Declaration
Swift
public func refreshLegAttributes(from refreshedRoute: RouteRefreshSource, legIndex: Int, legShapeIndex: Int)Parameters
refreshedRouteThe route containing leg attributes to merge into the receiver. If this route contains fewer legs than the receiver, this method skips legs from the beginning of the route to make up the difference, so that merging the attributes from a one-leg route affects only the last leg of the receiver.
legIndexThe index of a leg, from which to start applying the refreshed attributes.
legShapeIndexIndex of a geometry of the
legIndexleg, where to start refreshing from. -
Merges the incidents of the given route’s legs into the receiver’s legs.
Declaration
Swift
public func refreshLegIncidents(from refreshedRoute: RouteRefreshSource)Parameters
refreshedRouteThe route containing leg incidents to merge into the receiver. If this route contains fewer legs than the receiver, this method skips legs from the beginning of the route to make up the difference, so that merging the incidents from a one-leg route affects only the last leg of the receiver.
-
Merges the incidents of the given route’s legs into the receiver’s legs.
Declaration
Swift
public func refreshLegIncidents(from refreshedRoute: RouteRefreshSource, legIndex: Int, legShapeIndex: Int)Parameters
refreshedRouteThe route containing leg incidents to merge into the receiver. If this route contains fewer legs than the receiver, this method skips legs from the beginning of the route to make up the difference, so that merging the incidents from a one-leg route affects only the last leg of the receiver.
legIndexThe index of a leg, from which to start applying the refreshed incidents.
legShapeIndexIndex of a geometry of the
legIndexleg, where to start refreshing from. -
Merges the closures of the given route’s legs into the receiver’s legs.
Declaration
Swift
public func refreshLegClosures(from refreshedRoute: RouteRefreshSource, legIndex: Int = 0, legShapeIndex: Int = 0)Parameters
refreshedRouteThe route containing leg closures to merge into the receiver. If this route contains fewer legs than the receiver, this method skips legs from the beginning of the route to make up the difference, so that merging the closures from a one-leg route affects only the last leg of the receiver.
legIndexThe index of a leg, from which to start applying the refreshed closures.
legShapeIndexIndex of a geometry of the
legIndexleg, where to start refreshing from.
Install in Dash
Route Class Reference