-
-
Save ChuckJHardy/472315fd830aaefcdd42ff0882e2f9b4 to your computer and use it in GitHub Desktop.
Google Maps Static map helper for Ruby on Rails
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 StaticMapHelper | |
def static_map_for(location, options = {}) | |
params = { | |
:center => [location.lat, location.lng].join(","), | |
:zoom => 15, | |
:size => "300x300", | |
:markers => [location.lat, location.lng].join(","), | |
:sensor => true | |
}.merge(options) | |
query_string = params.map{|k,v| "#{k}=#{v}"}.join("&") | |
image_tag "http://maps.googleapis.com/maps/api/staticmap?#{query_string}", :alt => location.name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment