Last active
December 19, 2015 12:38
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# 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 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# 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 %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.