optimizeWaypoints property

bool? optimizeWaypoints
final

By default, the Directions service calculates a route through the provided waypoints in their given order.

If set to true will allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order. (This optimization is an application of the traveling salesperson problem.) Travel time is the primary factor which is optimized, but other factors such as distance, number of turns and many more may be taken into account when deciding which route is the most efficient. All waypoints must be stopovers for the Directions service to optimize their route.

If you instruct the Directions service to optimize the order of its waypoints, their order will be returned in the waypoint_order field within the DirectionsRoute object. The waypointOrder field returns values which are zero-based.

Implementation

final bool? optimizeWaypoints;