Created
May 30, 2013 03:16
-
-
Save woods/5675532 to your computer and use it in GitHub Desktop.
Helpers for embedding or displaying links to a Google map
This file contains 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
module GoogleMapsHelper | |
# Returns a URL to use in an iframe for embedding a Google map | |
# Reference: http://asnsblues.blogspot.com/2011/11/google-maps-query-string-parameters.html | |
def google_maps_embed_url(address) | |
"#{google_maps_url(address)}&output=embed" | |
end | |
# Returns a URL to use for linking to a Google map | |
# Reference: http://asnsblues.blogspot.com/2011/11/google-maps-query-string-parameters.html | |
def google_maps_url(address) | |
"https://maps.google.com/maps?f=q&t=m&ie=UTF8&q=#{u address}" | |
end | |
end |
This file contains 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
<%= content_tag :iframe, nil, | |
src: google_maps_embed_url(@address), | |
width: 300, | |
height: 300, | |
frameborder: 0, | |
scrolling: 'no', | |
marginheight: 0, | |
marginwidth: 0 %> | |
<br /> | |
<small> | |
<%= link_to "View Larger Map", google_maps_url(@address) %> | |
</small> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment