есть две функции.
function calcRoute() {
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
var route = response.routes[0];
var summaryPanel = document.getElementById('directions_panel');
var f;
var f1;
summaryPanel.innerHTML = '';
var a1;
var a;
// For each route, display summary information.
for (var i = 0; i < route.legs.length; i++) {
f=(route.legs[i].end_location.lat()-route.legs[i].start_location.lat())/10 ;
f1=(route.legs[i].end_location.lng()-route.legs[i].start_location.lng())/10;
summaryPanel.innerHTML +=' Координаты начала '+ route.legs[i].start_location + ' среднее ';
summaryPanel.innerHTML += f + '<br>';
summaryPanel.innerHTML += f1 + '<br>';
summaryPanel.innerHTML += 'Время:'+route.legs[i].duration.text + '<br><br>';
var markers = [];
for(var k=1; k<=9; ++k)
markers[k-1] = new google.maps.Marker({
position: new google.maps.LatLng(route.legs[i].start_location.lat()+f*k, route.legs[i].start_location.lng()+f1*k),
icon: destinationIcon,
map: map
});
a=route.legs[i].start_location.lat()+f;
a1=route.legs[i].start_location.lng()+f1;
}
}
});
}
function calcRoute1() {
var start = document.getElementById('start').value;
var end1 = new google.maps.LatLng(calcRoute(a), calcRoute(a1));
Uncaught ReferenceError: a is not defined
var request1 = {
origin: start,
destination: end1,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService1.route(request1, function(response1, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response1);
var route1 = response1.routes[0];
var summaryPanel1 = document.getElementById('directions_panel1');
summaryPanel1.innerHTML = '';
// For each route, display summary information.
for (var i = 0; i < route.legs.length; i++) {
summaryPanel1.innerHTML += 'Время:'+route.legs[i].duration.text + '<br><br>';
});
}
}
});
}
нужно передать из функции calcRoute() в функцию calcRoute1() переменную a.