Created
August 4, 2015 19:16
-
-
Save chipoglesby/9d136ad01b204ece8e09 to your computer and use it in GitHub Desktop.
Geocode postal addresses
This file contains hidden or 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_Addresses() { | |
| var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
| var locationInfo = sheet.getRange(1, 1, sheet.getLastRow() - 1, 1).getValues(); | |
| var geoResults, lat, lng; | |
| for (var i = 0; i < locationInfo.length; i++) { | |
| geoResults = Maps.newGeocoder().geocode(locationInfo[i]); | |
| // Get the latitude and longitude | |
| lat = geoResults.results[0].geometry.location.lat; | |
| lng = geoResults.results[0].geometry.location.lng; | |
| sheet.getRange(i+1, 2, 1, 1).setValue(lat + "," + lng); | |
| Utilities.sleep(1000); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment