Last active
December 22, 2015 18:09
-
-
Save joyrexus/6510992 to your computer and use it in GitHub Desktop.
Find geo-coordinates for an address.
This file contains 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
#!/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