Question

Has anyone that works with the Rails Geokit::Geocoder been able to geocode with it over the last few weeks?

I can no longer get an address to geocode regardless of its format or if the string itself can be entered directly into google maps and returns a single result.

Neither

Address1, address2, city, postcode

nor

London, UK

formats will return anything other than "Google was unable to geocode address:...".

has the service been stopped or perhaps other users are consuming the daily geocoding limit as soon as it reset?

Ruby 1.8.7

Rails 2.3.15

Geokit 1.6.5

Edit:

After further investigation I've determined that the comment on geocoding limits is not the case, my api key didn't resolve the issue.

--- Used solution ---

This is the alternative I used (before an answer was posted).

def self.geocodeAddress address
    address.gsub!(/,/, ",+").gsub!(/\s/, "")
    res = MultiJson.load open("http://maps.googleapis.com/maps/api/geocode/json?address=#{address}&sensor=false").read()
    res["results"].first["geometry"]["location"] if res["status"] == "OK"
end

Can't remember why the /\s/ replacement was made, I've left it in for transparency..

Was it helpful?

Solution

Geokit previously used Google Maps API v2. That API has been depricated. To make Geokit use the new version with rails, update your geokit_config.rb file:

Geokit::Geocoders::provider_order = [:google3, :us]
Geokit::Geocoders::Google3Geocoder = Geokit::Geocoders::GoogleGeocoder3

See this issue for reference: https://github.com/geokit/geokit/issues/86

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top