【发布时间】:2019-12-06 20:00:41
【问题描述】:
我在问一个与这篇帖子非常相似的问题:How to add my key to this google app script?
但是,该帖子上的答案不再有效(使用 Maps.setAuthentication(clientId, signingKey)),因为它用于 Google Maps API 高级计划,该计划不再适用于新客户。 见这里:https://developers.google.com/apps-script/reference/maps/maps#setAuthentication(String,String)
基本上,我使用以下代码在 google 表格中查找包含 10,000 项地址列表的邮政编码。该代码有效,但我收到“一天内调用了太多次服务:地理编码(第 7 行)”错误。我生成了一个地理编码 API 密钥和计费帐户,但不知道在哪里插入它。我对谷歌脚本代码不是很熟悉。
function geo2zip(a) {
var response=Maps.newGeocoder()
.reverseGeocode(lat(a),long(a));
return response.results[0].formatted_address.split(',')[2].trim().split(' ')[1];
}
function lat(pointa) {
var response = Maps.newGeocoder()
.geocode(pointa);
return response.results[0].geometry.location.lat
}
function long(pointa) {
var response = Maps.newGeocoder()
.geocode(pointa);
return response.results[0].geometry.location.lng
}
【问题讨论】:
标签: google-maps google-apps-script google-sheets google-cloud-platform geocode