Last active
May 12, 2020 14:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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