Geokit is Ruby 1.9.1 compatible!

What can Geokit do for you?


Find near latitude and longitude:

Store.find(:all, :origin =>[37.792,-122.393], :within=>10)

Find near an address:

Store.find(:all, :origin=>'100 Spear st, San Francisco, CA', :within=>10)

Order by distance from the center of a zipcode:

Store.find(:all, :origin=>'94117', :within=>10,
           :order=>'distance asc')

Combine distance conditions with regular conditions

Store.find(:all, :origin=>'94117', :within=>10, 

Geocode an address:

include Geokit::Geocoders
res=MultiGeocoder.geocode('100 Spear st, San Francisco, CA')
puts res.ll # ll=latitude,longitude

Find the address near a latitude/longitude (reverse geocoding):

include Geokit::Geocoders
puts res.full_address
>> 36-98 Mission St, San Francisco, CA 94105, USA

Find distances, headings, endpoints, and midpoints:

distance=home.distance_from(work, :units=>:miles)
heading=home.heading_to(work) # result is in degrees, 0 is north
endpoint=home.endpoint(90,2)  # two miles due east

Test if a point is contained within bounds:,ne_point)

Find within bounds:,ne_point)
Store.find :all, :bounds=>bounds

Find distance to a second location with on-the-fly geocoding:

s = Store.find(:first)
distance = s.distance_from('100 spear st, San Francisco, CA')

Ready to Install?

1. Install the Rails plugin:

script/plugin install git://

2. Add this line to your config/environment.rb

(inside the do |config| block)

config.gem "geokit"

This informs Rails of the gem dependency.

3. Tell Rails to install the gem:

rake gems:install

And you're good to go! If you're running an older verion of Rails, just install the gem manually: sudo gem install geokit

If you're having trouble with dependencies ....

Try installing the gem manually, then adding a require 'geokit' to the top of vendor/plugins/geokit-rails/init.rb and/or config/geokit_config.rb.

Need Some Help?

Join the Geokit Google group. Others may have had the same problem, or can help answer your question.

Rails + Geokit = easier mapping apps.
Geokit provides geocoding, location finders, distance calculations, and more.

The gem (geokit-gem) provides the fundamental location-based operations.

The Rails plugin (geokit-rails) mixes location finders into ActiveRecord.

Created by Andre Lewis and Bill Eisenhauer


Also by Andre Lewis