function myFunction() {
const api_url = "https://mreversegeocoder.gsi.go.jp/reverse-geocoder/LonLatToAddress";
const sheet = SpreadsheetApp.getActiveSheet();
const lastRow = sheet.getLastRow();
console.log(lastRow);
for (let i = 2; i <= lastRow; i++) {
let cell = sheet.getRange(i, 3);
if (cell.isBlank()) {
let data = sheet.getRange(i, 1, 1, 3).getValues();
let lat = String(data[0][0]);
let lon = String(data[0][1]);
let url = api_url + "?lat=" + lat + "&lon=" + lon;
let response = UrlFetchApp.fetch(url).getContentText();
Utilities.sleep(3000);
let json = JSON.parse(response);
let place = "unknown";
if ("results" in json) {
place = json["results"]["lv01Nm"];
}
console.log(place);
cell.setValue(place)
}
}
}