Credit: Google Spreadsheets function to find distance between cities
function getDirection(city1, city2, unit) {
var directions = Maps.newDirectionFinder()
.setOrigin(city1).setDestination(city2)
.setMode(Maps.DirectionFinder.Mode.DRIVING)
.getDirections();
var d = directions.routes[0].legs[0].distance.text;
var distance, value = d.split(" ")[0].replace(",", ""), text = d.split(" ")[1];
if(text == unit) {
distance = value;
} else if(text == "km" && unit == "mi") {
distance = value / 1.6;
} else {
distance = value * 1.6;
}
return Math.round(distance);
}
I have used this code snippet in one of my sheets. I am working on a dataset with roughly 6000 entries and I am getting some errors because of the large volume.
Script invoked too many times per second for this Google user account. (line 0).
Service invoked too many times for one day: route. (line 4).
I considered purchasing a Google Apps business account to increase my quota, but that might not even help. Do you maybe have any advice for me in this regard?