Search code examples
macosterminalapplescriptapple-maps

Return Coordinates of Address with Apple Maps on Mac


I would like to use terminal (or applescript) to get the lat and long of an address. Is this possible on OS X Mavericks now that there is an Apple Maps app in OS X?


Solution

  • Try to use the Google Maps API instead:

    curl -sG --data-urlencode 'address=1600 Pennsylvania Ave NW Washington DC' 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false'|jq '.results[0].geometry.location[]'

    You can install jq with brew install jq. Or replace the jq command with awk '/^ *"lat"/{print $3;getline;print $3;exit}'.