Skip to content

Instantly share code, notes, and snippets.

@nicholalexander
Last active December 26, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholalexander/7146138 to your computer and use it in GitHub Desktop.
Save nicholalexander/7146138 to your computer and use it in GitHub Desktop.

installing gmaps4rails

##controller

@hash = Gmaps4rails.build_markers(@posts) do |post, marker|
    marker.lat post.latitude.to_f
    marker.lng post.longitude.to_f
    marker.picture({
              :url => post.image.url(:thumb),
              :width   => 50,
              :height  => 50
      }) 

##view

<script>
	handler = Gmaps.build('Google');
  	handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
  	markers = handler.addMarkers(<%=raw @hash.to_json %>);
  	handler.bounds.extendWith(markers);
  	handler.fitMapToBounds();
	});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment