This is what I have for displaying the map with markers
<%= javascript_tag do%>
var handler = Gmaps.build('Google');
handler.buildMap({ internal: {id: 'multi_markers'}}, function(){
var markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
<%end%>
<% content_for :scripts do %>
<script type="text/javascript" charset="utf-8">
Gmaps.map.callback = function() {
if (Gmaps.map.markers.length == 1) {
var marker = Gmaps.map.markers[0];
var infowindow = marker.infowindow;
infowindow.open(Gmaps.map.map, marker);
}
}
</script>
<% end %>
Not exactly sure how should I be trying to have the infoWindows/markers open default on page load.
Thanks
The solution consists in triggering the
click
event on markers, then adjust map.Here is a working demo
And remove the part with
Gmaps.map.callback
, its for 1.x