2014-04-16 43 views
0

我在使用gmaps4rails infowindow時遇到了困難。我有一個應用程序,它使用json數據存儲在activerecord中成功顯示多個標記。我創建了一個局部以選擇附加信息的信息窗口顯示,但在每個標記被重複從PoliceAlert類的第一個實例相同的數據:gmaps4rails爲標記重複部分

控制器:

class StaticPagesController < ApplicationController 

def main 
@police_alerts = PoliceAlert.all 
@police_hash = Gmaps4rails.build_markers(@police_alerts) do |police_alert, marker| 
    marker.lat(police_alert.latitude) 
    marker.lng(police_alert.longitude) 
    marker.json({:id => police_alert.id }) 
    marker.picture({ 
    "url" => view_context.image_path('/assets/police.png'), 
    "width" => 32, 
    "height" => 37 
    }) 
    marker.infowindow render_to_string(:partial => '/layouts/police_alerts_infowindow', :locals => { :police_alert => police_alert }) 
end 
end 

部分:

<% PoliceAlert.find do |police_alert| %> 
<%= police_alert.hundred_block_location %> 
<br><%= police_alert.event_clearance_description %></br> 
<%= police_alert.event_clearance_date %> 
<% end %> 

如何獲取標記以顯示每個police_alert的信息?非常感謝提前?

回答

0

不知道理解,但將其替換您的部分:

<%= police_alert.hundred_block_location %> 
<br/> 
<%= police_alert.event_clearance_description %> 
<br/> 
<%= police_alert.event_clearance_date %> 
+0

謝謝!那樣做了! –