【问题标题】:Google Sheets JSON Error: "Service invoked too many times for one day:"Google 表格 JSON 错误:“一天内调用的服务次数过多:”
【发布时间】:2016-06-11 03:49:31
【问题描述】:

我必须将经度和纬度转换为有用的地址(反向地理编码),我在 [Geo Scipt][1] 找到了一个很好的脚本

我遇到了每天请求太多的问题,我的问题是我如何才能只运行一次(从 ifttt 导入数据时)而不是每次打开这个 google 表?

function getLat(address) {
  if (address == '') {
    Logger.log("Must provide an address");
    return;
  }
  var geocoder = Maps.newGeocoder();
  var location;
    // Geocode the address and plug the lat, lng pair into the
    // 2nd and 3rd elements of the current range row.
    location = geocoder.geocode(address);
    // Only change cells if geocoder seems to have gotten a
    // valid response.
    if (location.status == 'OK') {
      lat = location["results"][0]["geometry"]["location"]["lat"];
 return lat;
    }
};

function getLon(address) {
  if (address == '') {
    Logger.log("Must provide an address");
    return;
  }
  var geocoder = Maps.newGeocoder();
  var location;
    // Geocode the address and plug the lat, lng pair into the
    // 2nd and 3rd elements of the current range row.
    location = geocoder.geocode(address);
    // Only change cells if geocoder seems to have gotten a
    // valid response.
    if (location.status == 'OK') {
      lng = location["results"][0]["geometry"]["location"]["lng"];
 return lng;
  }
};

function getAdd(lat, lng) {
// Return Address by taking the coordinates and reverse geocoding.
if (lat == "") {
return "You have to provide latitudinal coordinates to the place"
} if (lng == ""){
return "You have to provide longitudinal coordinates to the place"
}

var response = Maps.newGeocoder().reverseGeocode(lat, lng); //Call the reverse Geocode service
for (var i = 0; i < response.results.length; i++) {
var result = response.results[i];

return result.formatted_address; //Output full address in cell
Utilities.sleep(Math.random() * 500);
  }
};

【问题讨论】:

  • 你现在如何运行这些函数?他们不会自己跑。

标签: javascript json google-maps google-apps-script google-sheets


【解决方案1】:

Service invoked too many times for one day 表示给定的服务超过了一天的总允许执行时间。它最常见于在触发器上运行的脚本,其每日限制低于手动执行的脚本。而不是谷歌表格,尝试use Fusion Tables

每次在电子表格中使用自定义函数时,Google 表格都会单独调用 Apps 脚本服务器。如果您的电子表格包含数十个(或数百个或数千个!)自定义函数调用,则此过程可能会很慢。使用 Maps API and Fusion Table 阅读 Map your data 可能会有所帮助

如果脚本达到配额或限制,它将抛出异常并显示一条消息,有关此的更多信息,请点击此链接:https://developers.google.com/apps-script/guides/services/quotas#current_limitations

【讨论】:

  • Fusion Tables 已弃用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-23
相关资源
最近更新 更多