Waypoint
A Waypoint object indicates a location along a route. It may be the route’s origin or destination, or it may be another location that the route visits. A waypoint object indicates the location’s geographic location along with other optional information, such as a name or the user’s direction approaching the waypoint. You create a RouteOptions object using waypoint objects and also receive waypoint objects in the completion handler of the Directions.calculate(_:completionHandler:) method.
-
-
-
Initializes a new waypoint object with the given geographic coordinate and an optional accuracy and name.
It is recommended that the value of this argument be greater than the
horizontalAccuracyproperty of aCLLocationobject obtained from aCLLocationManagerobject. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway or inside a building. -
Initializes a new waypoint object with the given
CLLocationobject and an optional heading value and name.Note
This initializer is intended for
CLLocationobjects created using theCLLocation(latitude:longitude:)initializer. If you intend to use aCLLocationobject obtained from aCLLocationManagerobject, consider increasing thehorizontalAccuracyor set it to a negative value to avoid overfitting, since theWaypointclass’scoordinateAccuracyproperty represents the maximum allowed deviation from the waypoint. There is a high likelihood that the user may be located some distance away from a navigable road, for instance if the user is currently on a driveway or inside a building.
-
The geographic coordinate of the waypoint.
-
The radius of uncertainty for the waypoint, measured in meters.
For a route to be considered viable, it must enter this waypoint’s circle of uncertainty. The
coordinateproperty identifies the center of the circle, while this property indicates the circle’s radius. If the value of this property is negative, a route is considered viable regardless of whether it enters this waypoint’s circle of uncertainty, subject to an undefined maximum distance.By default, the value of this property is
nil. -
The geographic coordinate of the waypoint’s target.
The waypoint’s target affects arrival instructions without affecting the route’s shape. For example, a delivery or ride hailing application may specify a waypoint target that represents a drop-off location. The target determines whether the arrival visual and spoken instructions indicate that the destination is “on the left” or “on the right”.
By default, this property is set to
nil, meaning the waypoint has no target. This property is ignored on the first waypoint of aRouteOptionsobject, on any waypoint of aMatchOptionsobject, or on any waypoint of aRouteOptionsobject ifDirectionsOptions.includesStepsis set tofalse.This property corresponds to the
waypoint_targetsquery parameter in the Mapbox Directions and Map Matching APIs. -
A Boolean value indicating whether the waypoint may be snapped to a closed road in the resulting
RouteResponse.If
true, the waypoint may be snapped to a road segment that is closed due to a live traffic closure. This property isfalseby default. This property corresponds to thesnapping_include_closuresquery parameter in the Mapbox Directions API. -
A Boolean value indicating whether the waypoint may be snapped to a statically (long-term) closed road in the resulting
RouteResponse.If
true, the waypoint may be snapped to a road segment statically closed, that is long-term (for example, road under construction). This property isfalseby default. This property corresponds to thesnapping_include_static_closuresquery parameter in the Mapbox Directions API. -
The straight-line distance from the coordinate specified in the query to the location it was snapped to in the resulting
RouteResponse.By default, this property is set to
nil, meaning the waypoint has no snapped distance. -
The layer of road that the waypoint is positioned which is used to filter the road segment that the waypoint will be placed on in Z-order. It is useful for avoiding ambiguity in the case of multi-level roads (such as a tunnel under a road).
This property corresponds to the
layersquery parameter in the Mapbox Directions API. If a matching layer is not found, the Mapbox Directions API will choose a suitable layer according to the other providedDirectionsOptionsandWaypointproperties.By default, this property is set to
nil, meaning the route from theWaypointwill not be influenced by a layer of road.
-
The direction from which a route must approach this waypoint in order to be considered viable.
This property is measured in degrees clockwise from true north. A value of 0 degrees means due north, 90 degrees means due east, 180 degrees means due south, and so on. If the value of this property is negative, a route is considered viable regardless of the direction from which it approaches this waypoint.
If this waypoint is the first waypoint (the source waypoint), the route must start out by heading in the direction specified by this property. You should always set the
headingAccuracyproperty in conjunction with this property. If theheadingAccuracyproperty is set tonil, this property is ignored.For driving directions, this property can be useful for avoiding a route that begins by going in the direction opposite the current direction of travel. For example, if you know the user is moving eastwardly and the first waypoint is the user’s current location, specifying a heading of 90 degrees and a heading accuracy of 90 degrees for the first waypoint avoids a route that begins with a “head west” instruction.
You should be certain that the user is in motion before specifying a heading and heading accuracy; otherwise, you may be unnecessarily filtering out the best route. For example, suppose the user is sitting in a car parked in a driveway, facing due north, with the garage in front and the street to the rear. In that case, specifying a heading of 0 degrees and a heading accuracy of 90 degrees may result in a route that begins on the back alley or, worse, no route at all. For this reason, it is recommended that you only specify a heading and heading accuracy when automatically recalculating directions due to the user deviating from the route.
By default, the value of this property is
nil, meaning that a route is considered viable regardless of the direction of approach. -
The maximum amount, in degrees, by which a route’s approach to a waypoint may differ from
headingin either direction in order to be considered viable.A value of 0 degrees means that the approach must match the specified
headingexactly – an unlikely scenario. A value of 180 degrees or more means that the approach may be as much as 180 degrees in either direction from the specifiedheading, effectively allowing a candidate route to approach the waypoint from any direction.If you set the
headingproperty, you should set this property to a value such as 90 degrees, to avoid filtering out routes whose approaches differ only slightly from the specifiedheading. Otherwise, if theheadingproperty is set to a negative value, this property is ignored.By default, the value of this property is
nil, meaning that a route is considered viable regardless of the direction of approach. -
A Boolean value indicating whether arriving on opposite side is allowed. This property has no effect if
DirectionsOptions.includesStepsis set tofalse. This property corresponds to theapproachesquery parameter in the Mapbox Directions and Map Matching APIs.
-
The name of the waypoint.
This property does not affect the route, but the name is included in the arrival instruction, to help the user distinguish between multiple destinations. The name can also help you distinguish one waypoint from another in the array of waypoints passed into the completion handler of the
Directions.calculate(_:completionHandler:)method.
-
A Boolean value indicating whether the waypoint is significant enough to appear in the resulting routes as a waypoint separating two legs, along with corresponding guidance instructions.
By default, this property is set to
true, which means that each resulting route will include a leg that ends by arriving at the waypoint asRouteLeg.destinationand a subsequent leg that begins by departing from the waypoint asRouteLeg.source. Otherwise, if this property is set tofalse, a single leg passes through the waypoint without specifically mentioning it. Regardless of the value of this property, each resulting route passes through the location specified by thecoordinateproperty, accounting for approach-related properties such asheading.With the Mapbox Directions API, set this property to
falseif you want the waypoint’s location to influence the path that the route follows without attaching any meaning to the waypoint object itself. With the Mapbox Map Matching API, use this property when theDirectionsOptions.includesStepsproperty istrueor whencoordinatesrepresents a trace with a high sample rate. This property has no effect ifDirectionsOptions.includesStepsis set tofalse, or ifMatchOptions.waypointIndicesis non-nil. This property corresponds to theapproachesquery parameter in the Mapbox Directions and Map Matching APIs. -
-
Install in Dash
Waypoint Class Reference