Skip to content

Instantly share code, notes, and snippets.

@mdoel
Created May 17, 2009 00:12
Show Gist options
  • Save mdoel/112853 to your computer and use it in GitHub Desktop.
Save mdoel/112853 to your computer and use it in GitHub Desktop.
desc "Use Google to get and XML geocode response for address"
task :geocode => :environment do
require 'geokit'
address_str = ENV['address']
if address_str.nil?
puts "Usage: rake geocode address='address to geocode'"
end
url = "http://maps.google.com/maps/geo?q=#{Geokit::Inflector::url_escape(address_str)}&output=xml&key=#{Geokit::Geocoders::google}&oe=utf-8"
res = Net::HTTP.get_response(URI.parse(url))
puts res
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment