Created
November 1, 2018 13:55
-
-
Save alexfu/caef5ff703471fc553884a87f37d5c70 to your computer and use it in GitHub Desktop.
Bash script that geocodes a location.
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
#!/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