AI-generated Key Takeaways
-
GMSNavigationRoutingOptions
is an immutable class used to define routing logic preferences, such as route ranking and alternate route generation, in navigation. -
Developers can specify routing strategies based on time or distance, control the number of alternate routes, and even set target distances for route ranking.
-
Initialization methods allow for setting the desired routing behavior using
GMSNavigationRoutingStrategy
,GMSNavigationAlternateRoutesStrategy
, or target distances. -
When using target distances for route ranking, it's crucial to keep them updated for optimal results, and currently, target distance is only supported for the first destination.
GMSNavigationRoutingOptions
@interface GMSNavigationRoutingOptions : NSObject <NSCopying, NSMutableCopying>
An immutable class that contains options related to routing logic (e.g., routing strategy).
-
Specifies the ranking order of routes, either by time, or by distance.
Declaration
Swift
var routingStrategy: GMSNavigationRoutingStrategy { get }
Objective-C
@property (nonatomic, readonly) GMSNavigationRoutingStrategy routingStrategy;
-
The alternate routes strategy used when setting destinations.
Declaration
Swift
var alternateRoutesStrategy: GMSNavigationAlternateRoutesStrategy { get }
Objective-C
@property (nonatomic, readonly) GMSNavigationAlternateRoutesStrategy alternateRoutesStrategy;
-
An array of target distances. A target distance is used to rank routes to a destination by the absolute delta to it from smallest to largest. The elements should be non-negative integers. Don’t set
GMSNavigationAlternateRoutesStrategy
and this field at the same time. Target distance is only supported for the first destination for now. So only put one positive integer in the array. If the first element is not a positive integer, the routing strategy defaults to the best routing strategy.Declaration
Swift
var targetDistancesMeters: [NSNumber]? { get }
Objective-C
@property (nonatomic, readonly, nullable) NSArray<NSNumber *> *targetDistancesMeters;
-
Initializes the routing options with routing strategy.
Declaration
Swift
init(routingStrategy: GMSNavigationRoutingStrategy)
Objective-C
- (nonnull instancetype)initWithRoutingStrategy: (GMSNavigationRoutingStrategy)routingStrategy;
Parameters
routingStrategy
Routing strategy that specifies the order of returned routes.
-
Initializes the routing options with an alternate routes strategy.
Declaration
Swift
init(alternateRoutesStrategy: GMSNavigationAlternateRoutesStrategy)
Objective-C
- (nonnull instancetype)initWithAlternateRoutesStrategy: (GMSNavigationAlternateRoutesStrategy)alternateRoutesStrategy;
Parameters
alternateRoutesStrategy
Alternate routes strategy that determines the number of returned alternate routes.
-
Initializes the routing options with target distances, and sets the routing strategy to
GMSNavigationRoutingStrategyDeltaToTargetDistance
. Ensure that target distances are always up-to-date when used.Declaration
Swift
init(targetDistancesMeters: [NSNumber])
Objective-C
- (nonnull instancetype)initWithTargetDistancesMeters: (nonnull NSArray<NSNumber *> *)targetDistancesMeters;
Parameters
targetDistancesMeters
Target distances for destinations. Each target distance is used to rank the routes to its corresponding destination by its absolute delta to the routes.