Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Last active December 22, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyrexus/6510992 to your computer and use it in GitHub Desktop.
Save joyrexus/6510992 to your computer and use it in GitHub Desktop.
Find geo-coordinates for an address.
#!/usr/bin/env coffee
'''
Find coords for an address.
See https://developers.google.com/maps/documentation/geocoding
'''
req = require 'request'
argv = require('optimist').argv
coords = (data) ->
console.log data.results[0].geometry.location
find = (address, callback) ->
url = "https://maps.googleapis.com/maps/api/geocode/json?address=#{address}&sensor=false"
req url, (err, res, body) -> callback JSON.parse(body)
address = argv._ or "27 Canterbury Way, Sewanee, TN 37375"
find address, coords
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment