I want to send one origin and multiple destinations to Google datamatrix api dynamically. It works fine if we use pass values directly as:
service.getDistanceMatrix({
origins: [document.getElementById("origin1").value],
destinations: ["kopargaon", "manmad"],
....
but if we push location in array and then passed to destination then it wont work. Eg
service.getDistanceMatrix({
origins: [document.getElementById("origin1").value],
destinations: [loc.toString()],
....
//loc is array of locations
API Considers all array elements as single location.
You are converting array to string, But the destination requires array as input.
service.getDistanceMatrix(
{
origins: [document.getElementById("origin1").value],
destinations: [loc], // .ToString converts array to string, Hence removed
....
//loc is array of locations
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.