I am having difficulty with gmaps4rails infowindow. I have an app which successfully displays multiple markers using json data stored in activerecord. I created a partial to select additional info to display in the infowindow, but the same data from the first instance of PoliceAlert class is being repeated in each marker:
Controller:
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
Partial:
<% PoliceAlert.find do |police_alert| %>
<%= police_alert.hundred_block_location %>
<br><%= police_alert.event_clearance_description %></br>
<%= police_alert.event_clearance_date %>
<% end %>
How do I get markers to display info for each police_alert? Thanks so much in advance?
Not sure to understand but replace your partial with: