Hallo,
I have installed geokit and when I use irb to get geocode from google
maps everything works fine
irb(main):001:0> require 'geokit'
=> true
irb(main):002:0> location = Geokit::Geocoders::GoogleGeocoder.geocode
('Athens')
=> #<Geokit::GeoLoc:0x99d7750 @all=[#<Geokit::GeoLoc:0x99d7750 ...>],
@street_address=nil, @city="Αθήνα", @state="Αττική", @zip=nil,
@country_code="GR", @province="Αθήνα", @success=true,
@precision="city", @full_address="Athens, Greece", @lat=37.97918,
@lng=23.716647, @provider="google", @country="Ελλάς", @accuracy=4,
@suggested_bounds=#<Geokit::Bounds:0x9e97e98 @sw=#<Geokit::LatLng:
0x9e97f10 @lat=37.9439911, @lng=23.6526173>, @ne=#<Geokit::LatLng:
0x9e97ed4 @lat=38.014352, @lng=23.7806767>>>
irb(main):003:0>
From my rails application
def update_cities
location = GoogleGeocoder.geocode('Athens')
end
from
http://localhost:3000/user/update_cities
I get the following error
URI::InvalidURIError in UserController#update_cities
bad URI(is not URI?):
http://maps.google.com/maps/geo?q=Athens&output=xml&key=xxxxxxxx&oe=utf-8
/opt/ruby1.9/lib/ruby1.9/1.9.1/uri/common.rb:156:in `split'
/opt/ruby1.9/lib/ruby1.9/1.9.1/uri/common.rb:174:in `parse'
/opt/ruby1.9/lib/ruby1.9/1.9.1/uri/common.rb:626:in `parse'
/opt/ruby1.9/lib/ruby1.9/gems/1.9.1/gems/geokit-1.5.0/lib/geokit/
geocoders.rb:162:in `do_get'
/opt/ruby1.9/lib/ruby1.9/gems/1.9.1/gems/geokit-1.5.0/lib/geokit/
geocoders.rb:139:in `block in call_geocoder_service'
/opt/ruby1.9/lib/ruby1.9/1.9.1/timeout.rb:52:in `timeout'
/opt/ruby1.9/lib/ruby1.9/gems/1.9.1/gems/geokit-1.5.0/lib/geokit/
geocoders.rb:139:in `call_geocoder_service'
/opt/ruby1.9/lib/ruby1.9/gems/1.9.1/gems/geokit-1.5.0/lib/geokit/
geocoders.rb:432:in `do_geocode'
/opt/ruby1.9/lib/ruby1.9/gems/1.9.1/gems/geokit-1.5.0/lib/geokit/
geocoders.rb:126:in `geocode'
/home/manos/Projects/epolis/app/controllers/user_controller.rb:35:in
`update_cities'
Can anyone help?
Thabk you