0
我能夠在mmaoid中使用gmaps4rails中的基本地圖顯示功能,這非常棒,但是Im缺乏更多高級功能。我想我錯過了一些基本知識並尋找指導。 我能夠獲得基本的地理編碼,以處理名爲緯度:經度和:gmaps的字段,但是當我嘗試使用數組時,如自述文件所示,我無處可去。我讀過wiki中的Mongoid技巧無濟於事。如何使用gmaps4rails在Mongoid數組中存儲地理編碼
任何人都可以指向正確的方向嗎?
更新; 由於伊夫變得沒有任何反應,這裏是一些代碼示例,
示範
工作;
class Account
include Mongoid::Document
include Gmaps4rails::ActsAsGmappable
acts_as_gmappable
field :account_no
field :owner_name
field :address
field :latitude, :type => Float
field :longitude, :type => Float
field :gmaps, :type => Boolean
def gmaps4rails_address
"#{self.address}"
end
end
不工作
class Account
include Mongoid::Document
include Gmaps4rails::ActsAsGmappable
acts_as_gmappable :position => :location
field :account_no
field :owner_name
field :address
field :location, :type => Array
def gmaps4rails_address
"#{self.address}"
end
end
根據在gmaps4rails代碼段自述這應該工作到地址地理編碼到位置數組,但我得到這個錯誤
NoMethodError: undefined method `gmaps' for #<Account:0x007fc47d051ba0>
最後我用我看見你的地方推薦的地理編碼器的寶石。 – SteveO7
不錯的選擇:它真的專注於地理編碼,其中gmaps4rails旨在顯示內容 – apneadiving