I know how to get distance between 2 locations using
var distance = require("google-distance-matrix");
distance.key('API-KEY');
distance.mode('driving');
distance.units('imperial');
var origins = [platlong.toString()];
var destinations = [dlatlong.toString()];
distance.matrix(origins, destinations, function(err,Data){
console.log(Data.rows[0].elements[0].distance.value);
}};
But how to get Cost Distance matrix of 3 or more locations
[
[0, 2, 3],
[2, 0, 4],
[3, 4, 0]
]
For using VRP Algorithm i need Cost Distance Matrix as of Above.
There is only one way i know to create the Cost Distance matrix is by looping m x n times, i.e for 3 locations 3 x 3 = 9 times.
In real time scenario for 15 locations i have to loop 15 x 15 = 225 times
So i need to provide the API-Key for 225 times which will be very costly.
Is there any way for finding the Cost Distance Matrix cheaply instead of looping m x n times by google distance matrix