2012-04-27 8 views
4

Google Maps V3 APIウェイポイントについては多くの質問がありますが、任意のウェイポイントのセットから最適な往復ルートを得る方法については触れていません。基本的には、ウェイトポイントの順序は、最適なパスが何であれ決定されるべきであり、必ずしもシステムに供給される順序によって決まるわけではありません。誰でもこれが可能かどうか知っていますか?Google Maps API V3 - 任意のウェイポイント経由で最適な往復ルートを取得する方法

答えて

8

V3 APIには「最適化」オプションがあります。あなたはそれを試しましたか? https://developers.google.com/maps/documentation/javascript/referenceから

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/directions

+0

から

セカンド。ありがとう! – VinnyD

+0

限られたウェイポイント以上でこれを行う方法を知っている人はいますか? –