问题
I have a set of 20,000 addresses and I need to find the distance between those and a set address. The program works but I keep encountering the "service invoked too many times in one day" error message. Does anyone know if there is a way to buy more "queries" from google?
Thanks!
Code I am using:
function DrivingMeters(origin, destination) {
var randnumber = Math.random()*10000;
Utilities.sleep(randnumber);
var directions = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.getDirections();
return directions.routes[0].legs[0].distance.value;
}
function DrivingMiles(origin, destination) {
return DrivingMeters(origin, destination)/1609.34;
}
function DrivingSeconds(origin, destination) {
var directions = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.getDirections();
return directions.routes[0].legs[0].duration.value;
}
function DrivingHours(origin, destination) {
return DrivingSeconds(origin, destination)/(60*60);
}
回答1:
by referring to "queries", you mean "quota". Different services have different daily quotas. A possible exception message is:
Service invoked too many times: Calendar.This indicates that the script called the given service too many times in one day.
for a normal consumer (gmail.com), this line is notable:
URL Fetch calls: 20,000 / day
(see here for all the documentation)
After doing a google search for "buy more apps script quota", there were no promising results. some workarounds suggested using other frameworks or splitting up quota from multiple users. My suggestion would be to look into upgrading from the "Consumer" level to the "Google Apps for Your Domain" level (or higher).
p.s. some sample code in your question may help, so we can narrow down which service you are trying to use, and if there are any possible ways to make your code more efficient.
来源:https://stackoverflow.com/questions/36164017/distances-in-google-sheets