Я ожидаю, что это будет выглядеть примерно так:
function getSchoolData() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('SchoolNames');//assume names in column A
var rg=sh.getRange(2,1,sh.getLastRow-1,1);//skip header assume 1 row
var vA=rg.getValues();
var shB=ss.getSheetByName('SchoolData');
var vB=[]
for(var i=0;i<vA.length;i++) {
vB.push(callgooglemapsapi(vA[i][0],sh));
Utilities.sleep(milliseconds);//you may need a delay in here
}
shB.getRange(2,1,vB.length,vB[0].length).setValues(vB);
}
function callgooglemapsapi(schoolname,sheetname) {
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName(sheetname)||ss.getActiveSheet();
var baseUrl="https://maps.googleapis.com/maps/api/place/findplacefromtext/json"
var key="AIzaSyDQlB5xlLhSQZhdIkBGR0WXiWPLVqMwKkM";
var qs="?input=" + encodeURIComponent(schoolname) + "&inputtype=textquery&fields=formatted_address,type,place_id,geometry,icon,id,name,permanently_closed,photos,place_id,plus_code,user_ratings_total&key="
var response = UrlFetchApp.fetch(baseUrl + qs + key);
var data = JSON.parse(response.getContentText());
return [schoolname,data["candidates"][0]["name"],data["candidates"][0]["formatted_address"],data["candidates"][0]["geometry"]["location"]["lng"],data["candidates"][0]["geometry"]["location"]["lat"],data["candidates"][0]["geometry"]["viewport"]["southwest"]["lng"],data["candidates"][0]["geometry"]["viewport"]["southwest"]["lat"],data["candidates"][0]["geometry"]["viewport"]["northeast"]["lng"],data["candidates"][0]["geometry"]["viewport"]["northeast"]["lat"],data["candidates"][0]["place_id"],data["candidates"][0]["photo_reference"],data["candidates"][0]["plus_code"],data["candidates"][0]["types"]];
}