Last active
September 14, 2016 13:23
-
-
Save Cheffheid/b736a7c6789f36f1162243cd8e871e93 to your computer and use it in GitHub Desktop.
Get map coordinates based on City, State cell data
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
/* | |
* Uses Google Code built in Maps Geocoder to obtain coordinates for a place in the US, for example: Tucson, AZ | |
* Usage: On a sheet, select "Tools" -> "Script editor" and paste below (modify output as necessary) | |
* Then set the value for a blank column to =getCoords(locationCell) | |
* ie. =getCoords(B2) | |
* Expected format: City, State | |
* Format example: Tucson, AZ | |
*/ | |
function getCoords(value) { | |
var response = Maps.newGeocoder().geocode(value); | |
Utilities.sleep(1000); | |
var coords = response.results[0].geometry.location.lat + ", " + response.results[0].geometry.location.lng; | |
return coords; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment