关于Google Maps V3 API航点的问题很多,但没有一个问题涉及如何从一组任意航路点获得最佳往返航线。基本上,称重点的顺序应由最佳路径确定,并且不一定由送入系统的顺序决定。有人知道这是否可能吗?
答案 0 :(得分:8)
V3 API中有一个“优化”选项。你试过吗?
optimizeWaypoints
If set to true, the DirectionService will attempt to re-order the supplied
intermediate waypoints to minimize overall cost of the route. If waypoints
are optimized, inspect DirectionsRoute.waypoint_order in the response to
determine the new ordering.
optimizeWaypoints (optional) specifies that the route using the supplied
waypoints may be optimized to provide the shortest possible route.
来自https://developers.google.com/maps/documentation/javascript/reference的第一段。
来自https://developers.google.com/maps/documentation/javascript/directions
的第二名