Skip to content

Instantly share code, notes, and snippets.

@alexfu
Created Nov 1, 2018
Embed
What would you like to do?
Bash script that geocodes a location.
#!/bin/bash
BASE_URL="https://maps.googleapis.com/maps/api/geocode/json"
API_KEY="" # Obtain an API key from https://developers.google.com/maps/documentation/geocoding/get-api-key
ADDRESS=$1
curl -s -G $BASE_URL --data-urlencode "address=$1" --data-urlencode "key=$API_KEY" | jq '.results[] | { name: .formatted_address, latLng: "\(.geometry.location.lat),\(.geometry.location.lng)" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment