Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calcRoute() {
- var a = [] // массив расстояний маршрутов
- var l = 0; // расстояние для маршрута
- for (var i = 0; i < 3; i++) {
- var start = document.getElementById('client').value;
- var end = locations[i];
- var request = {
- origin: start,
- destination: end,
- travelMode: 'DRIVING',
- unitSystem: google.maps.UnitSystem.METRIC
- };
- directionsService.route(request, function(result, status) {
- if (status == 'OK') {
- //directionsDisplay.setDirections(result);
- var routes = result.routes;
- var leg = routes[0].legs;
- l = leg[0].distance.text;
- alert(l);
- }
- });
- a[i] = l;
- }
- alert(a);
- }
Add Comment
Please, Sign In to add comment