Distances in google sheets

落花浮王杯 提交于 2020-08-11 18:01:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!