A Google Apps Script function to geocode addresses in Google Sheets using the Google Maps API.
This repository contains a Google Apps Script function for geocoding addresses using the Google Maps Geocoder service.
- Code.gs: Contains the
GEOCODE_GOOGLEfunction.
- Copy the function in
Code.gsinto your Google Apps Script project. - Call
GEOCODE_GOOGLE(address)from your script or a custom menu.- Pass a single address (string) to receive a latitude/longitude string.
- Pass an array of addresses (string[]) to receive an array of latitude/longitude strings.
var result = GEOCODE_GOOGLE("1600 Amphitheatre Parkway, Mountain View, CA");
Logger.log(result); // e.g. "37.422, -122.084"Within Google Sheets, you can use your custom function to geocode addresses directly in a cell. For example:
=GEOCODE_GOOGLE("1600 Amphitheatre Parkway, Mountain View, CA")
This will return the latitude/longitude in a single cell. If you pass in a range of cells containing multiple addresses, it will return an array of coordinates.
This small utility is provided as-is, without a support or release schedule. Issues and pull requests are welcome. See CONTRIBUTING.md for manual checks and SECURITY.md for private security reports.
MIT.