我使用自定义函数:
if (!address) {
throw new Error("No address specified!");
}
if (address.map) {
return address.map(LATLONG);
}
const key = ["address", address].join(",");
const value = getCache(key);
if (value !== null) return value;
const { results: [data = null] = [] } = Maps.newGeocoder().geocode(address);
if (data === null) {
throw new Error("Address not found!");
}
const { formatted_address } = data;
setCache(key, formatted_address);
return formatted_address;
};
在包含 2000 多行的整列中应用 =GOOGLEMAPS_ADDRESS(B59)
函数后,gs 服务器关闭,出现错误异常:服务在一天内调用了太多次:地理编码。 (第 71 行)。这不是因为地址不对,而是因为每次移动行,删除或添加后都会发生请求。在此图片上显示一些单元格获得值,但主要是错误。 https://i.stack.imgur.com/YSoRQ.png
如何将获得的值存储在活动单元格中并在值存储在活动单元格后从活动单元格中删除自定义函数?
答案 0 :(得分:2)
使用 trigger 代替公式:
function onEdit(e) {
e.range.offset(0,1).setValue(GOOGLEMAPS_ADDRESS(e.value));
}