Google Map V3, how to get list of best driving route for multiple destinations?

前端 未结 3 1052
情书的邮戳
情书的邮戳 2021-01-30 03:14

i would like to use Gmap API to calculate the best driving route for many destinations. I have read this page:

http://googlegeodevelopers.blogspot.de/2010/03/good-day-f

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 04:00

    The link you refer to explains how to do this: admittedly you also get back some directions information you don't care about, but you can simply ignore it.

    To be clear, you just make a directions request with some waypoints (say B,C and D) in addition to your origin and destination (A and E).

    If using the web service, ensure you set optimize:true before listing your waypoints, and check the waypoint_order array (near the bottom of the result for this url) to get the info you want:

    http://maps.googleapis.com/maps/api/directions/json?origin=Adelaide,SA&destination=Adelaide,SA&waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA&sensor=false
    

    If use the JS API, set optimizeWaypoints:true in your request.

    As always, be sure you're abiding by the terms of service (e.g. results from your web service request must be displayed on a Google Map)

提交回复
热议问题