我已经成功地获得了思维狮身人面像与关联模型上的地理定位一起工作。快乐的时光!思维狮身人面像 - 显示该协会的正确记录
但我现在需要它在Google地图上显示正确的关联记录。
该情景是has_many办事处的公司。办公室已经获得了lng,lat值。我正在寻找公司,并将办事处与它联系起来。
例如
define_index do
indexes :name, :sortable => true
indexes offices(:city), :as => :city
indexes offices(:postal_code), :as => :postal_code
has "RADIANS(offices.lat)", :as => :lat, :type => :float
has "RADIANS(offices.lng)", :as => :lng, :type => :float
has created_at
has updated_at
set_property :latitude_attr => 'lat'
set_property :longitude_attr => 'lng'
set_property :field_weights => { 'name' => 10,
'service_name' => 9,
'city' => 8 }
end
在y位置为X公司搜索/邮编完美的作品,显示出正确的公司已经在@geodist半径内得到所需的位置设有办事处。
例如
{:geo=>[0.9283660690549609, -0.050527407508941975], :sort_mode=>:expr, :sort_by=>"@weight * @weight/@geodist", :with=>{"@geodist"=>0.0..120700.8}, :conditions=>{:service_name=>"Business strategies"}, :page=>1, :per_page=>12, :star=>true}
产生的记录是公司的目标,而不是办公室,这是很好的列表视图,但我想说明的相关关联办公室的谷歌地图上的图标。
找到相关的办公室记录以在半径范围内显示的最佳方式是什么?
谢谢帕特,我需要也加入公司的服务,但我会尽力扭转加入:通过.... – 2011-05-30 18:37:36