How to get total driving distance with Google Maps API V3?

前端 未结 5 954
北海茫月
北海茫月 2020-12-05 04:47

I used to be able to get it like this:

directionsService.route(directionsRequest, function(directionsResult, directionsStatus) {
    var directionsRenderer =         


        
5条回答
  •  离开以前
    2020-12-05 05:25

    Take a look here:

    The Directions Results Object

    It looks like you now have to sum up each leg distance.

    legs[] contains an array of DirectionsLeg objects, each of which contains information about a leg of the route, from two locations within the given route. A separate leg will be present for each waypoint or destination specified. (A route with no waypoints will contain exactly one DirectionsLeg.) Each leg consists of a series of DirectionSteps.

提交回复
热议问题