var w = [], wp;
var rleg = directionsDisplay.directions.routes[0].legs[0];
data.start = {'lat': rleg.start_location.lat(), 'lng': rleg.start_location.lng()}
data.end = {'lat': rleg.end_location.lat(), 'lng': rleg.end_location.lng()}
var items = new Array();
for (var i = 1; i <= textboxes; i++) {
items[(i - 1)] = document.getElementById(i.toString()).value;
}
wp = document.getElementById('toAddress').value;
if (items.length > 0) {
w.push(wp)
}
for (var i = 0; i < items.length - 1; i++) {
wp = items[i];
if (wp !== "") {
w.push(wp);
}
}
data.waypoints = w;
var str = JSON.stringify(data)
locationroot.value = str;
return false;
Above code Output :
{"start":{"lat":22.3038548,"lng":70.80213219999996},"end":{"lat":22.470967,"lng":70.05772219999994},"waypoints":["jamnagar","kalavad"]}
but i want to output like this :
{"start":{"lat":22.3038548,"lng":70.80213219999996},"end":{"lat":22.470967,"lng":70.05772219999994},"waypoints":[[22.224905,70.62623409999992],[22.509108,70.22394120000001]]}