我正在使用Google表格函数来反转地理编码列表纬度/经度坐标。它看起来像这样:
为什么Google表格无法从Maps API中找到reverseGeocode方法?
function getAdd(lat, lng) {
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);
for (var i = 0; i < response.results.length; i++) {
var result = response.results[i];
Utilities.sleep(1000);
return result.formatted_address;
}
};
问题1:为什么谷歌表给我下面的错误:“找不到方法reverseGeocode(对象(类))”?
问题2:一旦我解决了这个问题,如何从结果数组中获取国家名称而不是结果中的完整地址呢?
感谢,尽管代码与在此之前,甚至工作,我仍然得到一个“无法找到方法”的错误。 – 2014-10-28 22:24:22
我无法解释为什么它以前工作。如果您遇到无法找到方法错误,则可能是您设置项目的方式存在问题。我测试了这个代码,它工作。我测试了你的代码,它没有,但没有给我一个无法找到错误。 – 2014-10-28 23:11:40