October31
GeoKit is a powerful geolocation framework for Ruby on Rails. It works nicely with Rails 2.1.2. Beware, SQLite doesn’t suffice, you need to switch to e.g. MySQL. The following commands in script/console helped quickly validate the install of the plugin:
include GeoKit::Geocoders
=> Object
start = MultiGeocoder.geocode(”Wippertstr. 2, Freiburg, Germany”)
=> #<GeoKit::GeoLoc:0×1fcfc64 @zip=”79115″, @state=”Baden-Württemberg”, @success=true, @provider=”google”, @lng=7.829245, @precision=”address”, @city=”Freiburg”, @country_code=”DE”, @lat=47.97692, @street_address=”Wippertstraße 2″, @full_address=”Wippertstraße 2, 79115 Freiburg, Germany”>
endpoint = MultiGeocoder.geocode(”Tokyo”)
=> #<GeoKit::GeoLoc:0×2049cf8 @zip=nil, @state=”Tokyo”, @success=true, @provider=”google”, @lng=139.682282, @precision=”state”, @city=nil, @country_code=”JP”, @lat=35.678451, @street_address=nil, @full_address=”Tokyo, Japan”>
home.distance_to(endpoint, :units => :miles)
=> 5945.92866816475