Skip to content


greatseth edited this page · 3 revisions
Clone this wiki locally


A simple, elegant library for getting geocoding information from Google Maps. Very much inspired by the google-geocode gem, but completely dependency free!


geo = API_KEY addresses = geo.locate ‘1600 Amphitheatre Parkway, Mountain View, CA’ addresses.size # 1, :locate always returns an Array address = addresses.first # ‘US’ # ‘Mountain View’ address.full_address # ‘1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA’ address.query # ‘1600 Amphitheatre Parkway, Mountain View, CA’ address.accuracy # 8 address.coordinates # [-122.084143, 37.421972, 0.0]

In the case of sufficiently vague queries, Google::Geo will return more than one:

addresses = geo.locate ‘hell’ addresses.size # 2 { |a| a.state } # [‘PA’, ‘NC’]

You can reverse geocode:

address = geo.locate(33.998671, -118.075926).first # => Pico Rivera address.state # => CA # => 90660 # => US address.full_address # => 4952-4958 Tobias Ave, Pico Rivera, CA 90660, USA

You can optionally enable the ability to get street view embed HTML for an Address:

require “google/geo/address/street_view” address.street_view_html :id => :street_view, :style => “width:640px; height:480px”


If you need to get the results in another language, you can set it like so:

geo = API_KEY, “de” geo.language = “en”

The language code can be anything listed on



© 2007-2009 Seth Thomas Rasmussen and released under the WTFPL. See the LICENSE file for details.

Something went wrong with that request. Please try again.