2013-06-12 28 views
1

爲谷歌API路線的一個問題谷歌阿比路沒有臺階

我想知道是否有可能作出對谷歌剛剛起步的完整路徑的時間和持續時間的請求沒有收到各中間步驟

感謝

http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false 

"routes" : [ 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 45.51014580, 
       "lng" : -73.55252489999999 
      }, 
      "southwest" : { 
       "lat" : 43.65331030, 
       "lng" : -79.38373319999999 
      } 
     }, 
     "copyrights" : "Datos de mapa ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "542 km", 
        "value" : 542385 
       }, 
       "duration" : { 
        "text" : "5h 14 min", 
        "value" : 18834 
       }, 
       "end_address" : "Montreal, Quebec, Canadá", 
       "end_location" : { 
        "lat" : 45.50857120, 
        "lng" : -73.55376740 
       }, 
       "start_address" : "Toronto, Ontario, Canadá", 
       "start_location" : { 
        "lat" : 43.65331030, 
        "lng" : -79.38276750 
       }, 

回答

1

使用DistanceMatrix API

的谷歌DIST ance Matrix API是一種爲來源和目的地矩陣提供旅行距離和時間的服務。返回的信息基於開始點和結束點之間的推薦路線,如Google Maps API計算得出的 ,並且由包含每對的持續時間和距離值的行組成。

0

http://maps.googleapis.com/maps/api/distancematrix/json?origins=Toronto&destinations=Montreal&sensor=false

(注的參數:出發地和目的地(複數形式,不同於方向API)

{ 
    "destination_addresses" : [ "Montreal, QC, Canada" ], 
    "origin_addresses" : [ "Toronto, ON, Canada" ], 
    "rows" : [ 
     { 
     "elements" : [ 
      { 
       "distance" : { 
        "text" : "542 km", 
        "value" : 542384 
       }, 
       "duration" : { 
        "text" : "5 hours 14 mins", 
        "value" : 18835 
       }, 
       "status" : "OK" 
      } 
     ] 
     } 
    ], 
    "status" : "OK" 
}