Skip to content

Instantly share code, notes, and snippets.

@dannvix
Created April 3, 2013 03:32
Show Gist options
  • Save dannvix/5298241 to your computer and use it in GitHub Desktop.
Save dannvix/5298241 to your computer and use it in GitHub Desktop.
convert latitude & longitude with Geocoder (Google Maps API)
#!/usr/bin/env ruby
require "geocoder"
def latlng_to_addr (lat, lng)
query_result = Geocoder.search("#{lat},#{lng}")
return query_result.first.formatted_address
end
if ARGV.length < 2
puts "usage: ./#{$0} <latitude> <longitude>"
exit(1)
end
lat, lng = ARGV[0], ARGV[1]
formatted_address = latlng_to_addr(lat, lng)
puts formatted_address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment