Skip to content

Instantly share code, notes, and snippets.

@auycro
Created July 15, 2021 08:10
Show Gist options
  • Save auycro/e06d0bfd9526ea6bc6ac14f14aa58c9a to your computer and use it in GitHub Desktop.
Save auycro/e06d0bfd9526ea6bc6ac14f14aa58c9a to your computer and use it in GitHub Desktop.
check lat lng appscript
function printLatLng(input){
var r = Maps.newGeocoder().geocode(input);
for (var i = 0; i < r.results.length; i++) {
var res = r.results[i];
console.log(input, res.geometry.location.lat + ", " + res.geometry.location.lng);
}
}
function myFunction() {
/** @OnlyCurrentDoc */
var sheet = SpreadsheetApp.getActiveSheet();
var addresses = sheet.getRange('D2:D82').getValues();
for (var i = 0; i < addresses.length; i++){
//if (addresses[i] != "") console.log(addresses[i]);
if (addresses[i] != ""){
var address = addresses[i];
var r = Maps.newGeocoder().geocode(address);
printLatLng(r);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment