Yahoo Geocoding in ruby…

Find lattitude and longitude of any address

Yahoo just released a new beta of their maps webservice. Here is a small ruby script (inspired by Rasmus’s PHP code ) that I wrote that returns Lattitude, Longitude of the address provided…

require 'open-uri'
require "rexml/document"
include REXML
url='http://api.local.yahoo.com/MapsService/V1/geocode?appid=yahoomap.rb&location='
puts 'Enter Location: '
address=gets
address=URI.escape(address)
result=URI(url+address).read
doc = Document.new result
r=doc.elements["/ResultSet/Result"]
print "Precision: ", r.attributes["precision"],"\n"
r.children.each { |c| print c.name, " : ",c.text,"\n"}

Comments 1

  1. David wrote:

    There’s a library for calling Yahoo’s geocoding API on RubyForge: http://rubyforge.org/projects/geocoder

    Posted 22 Mar 2006 at 9:24 pm

Trackbacks & Pingbacks 1

  1. From High Earth Orbit » Blog Archive » Spatial programming with Ruby on Rails on 19 Feb 2006 at 5:50 pm

    [...] Geocoding Ruby function with Yahoo! [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *