Skip to content

Instantly share code, notes, and snippets.

@eliotsykes
Last active December 19, 2015 12:38
Show Gist options
  • Save eliotsykes/5955962 to your computer and use it in GitHub Desktop.
Save eliotsykes/5955962 to your computer and use it in GitHub Desktop.
Getting started with gmaps4rails - a simple map with a single point centred on London, UK
<%# Shows a map centred on London, using the default marker/pin image. %>
<%= gmaps4rails([{:lat => 51.51, :lng => -0.12}].to_json) %>
<%= yield :scripts %><%# Usually yield :scripts goes just before the closing body tag %>
<%# Shows a map centred on London, using a draggable custom marker image *and* shadow. The shadow is optional. %>
<%=
gmaps4rails([{
:lat => 51.51, :lng => -0.12, :draggable => true,
:picture => image_path('/images/custom-marker.png'),
:width => 100, :height => 60,
:marker_anchor => [50, 60],
:shadow_picture => image_path('/images/custom-marker-shadow.png'),
:shadow_width => 150, :shadow_height => 60, :shadow_anchor => [50, 60]
}].to_json)
%>
<%= yield :scripts %><%# Usually yield :scripts goes just before the closing body tag %>
@eliotsykes
Copy link
Author

If your use case is simple, try using the Google Maps API directly. In the end I didn't use gmaps4rails, everything I needed was easier to do client-side with the API directly. This is left here in case it helps others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment