Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanLiebeschutz/9fe6cb9e1601a059937fef047da2176b to your computer and use it in GitHub Desktop.
Save DanLiebeschutz/9fe6cb9e1601a059937fef047da2176b to your computer and use it in GitHub Desktop.
Google apps script custom function that returns latitude and longitude values for given address using the Google Maps Geocoder.
function GEOCODE_GOOGLE(address) {
if (address!=""){
if (address.map) {
return address.map(GEOCODE_GOOGLE)
}
else {
var r = Maps.newGeocoder().geocode(address)
for (var i = 0; i < r.results.length; i++) {
var res = r.results[i]
return res.geometry.location.lat + ", " + res.geometry.location.lng
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment