total distance and time for all waypoints in google maps v3

前端 未结 1 779
闹比i
闹比i 2021-01-17 05:55

I have the following code for directions from google maps apiv3. This part is working good. If i have waypoints in my trip, at the top of each trip, it is showing the time a

1条回答
  •  时光说笑
    2021-01-17 06:17

    This is not a number:

    totaldistance = totaldistance + route.legs[i].distance.text;
    

    This works to give me the total distance in km:

     totaldistance = totaldistance + route.legs[i].distance.value;
    

    working example

    0 讨论(0)
提交回复
热议问题