3

Как получить время между двумя точками .Не расстояние а время . Знаю что надо использовать direction API

function calculateAndDisplayRoute(directionsService, directionsDisplay) {

  directionsService.route({
    origin: {lat: 37.77, lng: -122.447},  
    destination: {lat: 37.768, lng: -122.511},  

      travelMode: google.maps.TravelMode.WALKING
  }, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
      console.log(response);
    } else {
      window.alert('Directions request failed due to ' + status);
    }
  });
}

Как отсюда получить время между этими обьектами ???

1 ответ 1

2

Нашел ,время уже есть в ответе от сервера

var routes=response.routes;
      var leg =routes[0].legs;
       var lenght = leg[0].distance.text;
       var duration = leg[0].duration.text;
1
  • Если у кого-то будут вопросы прошу ,отвечу как смогу .
    – elik
    24 мар 2017 в 20:09

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.