我已經安裝了geokit gem和geokit-rails插件。我如下所示配置插件:http://github.com/andre/geokit-rails。然後,我產生一種新的模式 - 位置,它看起來像這樣:RoR - Geokit插件:爲什麼Location.find會給我一個空數組? (位置是「acts_as_mappable」的模型)
class Location < ActiveRecord::Base
acts_as_mappable :default_units => :kms
end
和控制器:
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
我還設置了一個位置表既LNG和LAT列在我的數據庫並把我的谷歌鍵在/config/initializers/geokit_config.rb 而現在,儘管@a給了我來自YahooGeocoder的正確結果(我也可以使用GoogleGeocoder),@ b是一個空數組。我知道@a是使用Geokit gem和@b使用Geokit-rails插件生成的,所以問題肯定與插件有關。當我使用@c=IpGeocoder.geocode('85.128.202.178')
時,我得到「成功:錯誤」......我在這裏做錯了什麼?