Geokit Plugin On Hosted Server

Hi, I am new here, but I hope somebody have a clue about this issue.

I am using rails 2.2.2 and the geokit gem. It works very good for a
while, but for unknown reason it stopped working on my hosting server,
but it still working alright on my developer machine.

Here it is what I got on script/console

-bash-3.2$ script/console production
Loading production environment (Rails 2.2.2)

include Geokit::Geocoders

=> Object

res = GoogleGeocoder.geocode 'New York'

=> #<Geokit::GeoLoc:0x2b6512375df0 @zip=nil, @precision="unknown",
@all=[#<Geokit::GeoLoc:0x2b6512375df0 ...>], @lng=nil, @success=false,
@state=nil, @lat=nil, @province=nil, @city=nil, @country_code=nil,
@street_address=nil, @full_address=nil>

But, on my local machine:

script/console production
Loading production environment (Rails 2.2.2)

include Geokit::Geocoders

=> Object

res = GoogleGeocoder.geocode 'New York'

=> #<Geokit::GeoLoc:0x1a25890 @country="USA", @city="New York",
@suggested_bounds=#<Geokit::Bounds:0x19272f4
@ne=#<Geokit::LatLng:0x19270c4 @lng=-73.7498543, @lat=40.8495342>,
@sw=#<Geokit::LatLng:0x1927290 @lng=-74.2620919, @lat=40.5788964>>,
@precision="city", @country_code="US", @street_address=nil, @accuracy=4,
@full_address="New York, NY, USA", @provider="google", @zip=nil,
@all=[#<Geokit::GeoLoc:0x1a25890 ...>], @lng=-74.0059731, @success=true,
@state="NY", @lat=40.7143528, @province="New York">

Any suggestion or clue ??

I seem to remember that you have to initialise Geokit with the
necessary information about your API keys for various geolocation
services. It looks here like the server hasn't got that configuration,
so it's not returning as many (or any) results. Is it possible your
deployment process to the server swaps out the configuration file or
something like that, and the one that the server ends up using doesn't
have the right API credentials in it?

Chris

Chris Mear wrote:

Loading production environment (Rails 2.2.2)

@full_address="New York, NY, USA", @provider="google", @zip=nil,
@all=[#<Geokit::GeoLoc:0x1a25890 ...>], @lng=-74.0059731, @success=true,
@state="NY", @lat=40.7143528, @province="New York">

Any suggestion or clue ??

I seem to remember that you have to initialise Geokit with the
necessary information about your API keys for various geolocation
services. It looks here like the server hasn't got that configuration,
so it's not returning as many (or any) results. Is it possible your
deployment process to the server swaps out the configuration file or
something like that, and the one that the server ends up using doesn't
have the right API credentials in it?

Chris

HI chris, thanks for your fast reply!

I looked at the apis key, but they seems to be working. In my config I
have:

config/gmaps_api_key.yml
development:
A-here-is-my-api-key-for-development-environment-g

test:

production:
ABA-here-is-my-api-key-for-production-environment-gMQ

*** EOF ***

and

config/initilializers/geokit_config.rb

if defined? Geokit

  # These defaults are used in Geokit::Mappable.distance_to and in
acts_as_mappable
  Geokit::default_units = :miles
  Geokit::default_formula = :sphere

  # This is the timeout value in seconds to be used for calls to the
geocoder web
  # services. For no timeout at all, comment out the setting. The
timeout unit
  # is in seconds.
  Geokit::Geocoders::request_timeout = 3

  # These settings are used if web service calls must be routed through
a proxy.
  # These setting can be nil if not needed, otherwise, addr and port
must be
  # filled in at a minimum. If the proxy requires authentication, the
username
  # and password can be provided as well.
  Geokit::Geocoders::proxy_addr = nil
  Geokit::Geocoders::proxy_port = nil
  Geokit::Geocoders::proxy_user = nil
  Geokit::Geocoders::proxy_pass = nil

  # This is your yahoo application key for the Yahoo Geocoder.
  # See http://developer.yahoo.com/faq/index.html#appid
  # and http://developer.yahoo.com/maps/rest/V1/geocode.html
  Geokit::Geocoders::yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'

  # This is your Google Maps geocoder key.
  # See http://www.google.com/apis/maps/signup.html
  # and
http://www.google.com/apis/maps/documentation/#Geocoding_Examples
  Geokit::Geocoders::google = 'REPLACE_WITH_YOUR_GOOGLE_KEY'

  # This is your username and password for geocoder.us.
  # To use the free service, the value can be set to nil or false. For
  # usage tied to an account, the value should be set to
username:password.
  # See http://geocoder.us
  # and http://geocoder.us/user/signup
  Geokit::Geocoders::geocoder_us = false

  # This is your authorization key for geocoder.ca.
  # To use the free service, the value can be set to nil or false. For
  # usage tied to an account, set the value to the key obtained from
  # Geocoder.ca.
  # See http://geocoder.ca
  # and http://geocoder.ca/?register=1
  Geokit::Geocoders::geocoder_ca = false

  # Uncomment to use a username with the Geonames geocoder
  #Geokit::Geocoders::geonames="REPLACE_WITH_YOUR_GEONAMES_USERNAME"

  # This is the order in which the geocoders are called in a failover
scenario
  # If you only want to use a single geocoder, put a single symbol in
the array.
  # Valid symbols are :google, :yahoo, :us, and :ca.
  # Be aware that there are Terms of Use restrictions on how you can use
the
  # various geocoders. Make sure you read up on relevant Terms of Use
for each
  # geocoder you are going to use.
  Geokit::Geocoders::provider_order = [:google]

  # The IP provider order. Valid symbols are :ip,:geo_plugin.
  # As before, make sure you read up on relevant Terms of Use for each
  # Geokit::Geocoders::ip_provider_order = [:geo_plugin,:ip]

end

I played around with both, putting the key directly on geokit_config.rb
and taking it out from gmaps_api_key.yml but, when I moved the key from
the yml file I started to receive the google API Key Alert.

Definitely, is not the api key issue. :frowning: