1

I have installed both geokit gem and geokit-rails plugin. I configured the plugin as shown here: http://github.com/andre/geokit-rails . Then I generated a new model - Location, which looks like this:

class Location < ActiveRecord::Base
acts_as_mappable :default_units => :kms
end

and a controller:
class TestController < ApplicationController
include GeoKit::Geocoders
include GeoKit::Mappable
def test1
@a=Geokit::Geocoders::YahooGeocoder.geocode 'Kaohsiung City, Taiwan' @b=Location.find(:all, :origin => '100 Spear st, San Francisco, CA', :within => 5)
end
end


I also set up a Locations table with both lng and lat columns in my database and put my google key in /config/initializers/geokit_config.rb And right now, altough @a is giving me correct results from YahooGeocoder (I can use GoogleGeocoder as well), @b is an empty array. I know @a is generated using Geokit gem and @b using Geokit-rails plugin, so the problem is definitely related to the plugin. When I use @c=IpGeocoder.geocode('85.128.202.178') I get "success: false" ... What am I doing wrong here?

sNiCKY
  • 1,823
  • 3
  • 18
  • 20

1 Answers1

0

Have you double checked your Location collection to ensure there exists a location within 5 kilometers of that street address? What happens if you do a similar lookup with an explicit latitude and longitude of a Location?

Re: @success=false, I'm having the same trouble with that IP (using IpGeocoder and MultiGeocoder).

>> @c=IpGeocoder.geocode('85.128.202.178')
=> #<Geokit::GeoLoc:0x1038df5f0 @success=false, @city="(Unknown City)", @province=nil, @street_address=nil, @lng=nil, @full_address=nil, @state=nil, @country_code="PL", @all=[#<Geokit::GeoLoc:0x1038df5f0 ...>], @lat=nil, @precision="unknown", @provider="hostip", @zip=nil>
>> @c=IpGeocoder.geocode('74.125.93.104')
=> #<Geokit::GeoLoc:0x1038d3c28 @success=true, @city="Manila", @province=nil, @street_address=nil, @lng=120.95, @full_address=nil, @state=nil, @country_code="PH", @all=[#<Geokit::GeoLoc:0x1038d3c28 ...>], @lat=14.5833, @precision="unknown", @provider="hostip", @zip=nil>
Brian Jordan
  • 2,377
  • 3
  • 21
  • 29