I am using Gmaps4rails gem. I could show markers without Infowindow, but after adding Infowindow in the controller, any markers do not appear. As the following, the Infowindow is rendered with partial.
What should I change the code? Thank you in advance.
clinics_controller.rb
@hash = Gmaps4rails.build_markers(@clinics) do |clinic, marker|
marker.lat clinic.latitude
marker.lng clinic.longitude
marker.json({:id => clinic.id})
marker.picture ({
"url" => "/images/red-dot.png",
"width" => 32,
"height" => 32
})
marker.infowindow render_to_string(partial: "map_infowindow", locals: {clinic: clinic})
end
_map_infowindow.html.erb
<h3><%= clinic.name %></h3>
Javascript
<script type="text/javascript" charset="utf-8">
handler = Gmaps.build('Google');
handler.buildMap({
provider: {
zoom: 15,
center: {lat: 35.765, lng: 139.62}
},
internal: {id: 'map'}},
function(){
markers = handler.addMarkers(<%= raw @hash.to_json %>);
}
);
</script>