Sha256: dd722f00cabcf3b4b553cd073c0b649a539c083ea4f058a0fb37c8536e1f125c
Contents?: true
Size: 933 Bytes
Versions: 1
Compression:
Stored size: 933 Bytes
Contents
module GoogleMapsRails module ViewHelpers def embed_google_maps(options = {}) width = options[:width] || 500 height = options[:height] || 500 lat = options[:lat] || nil long = options[:long] || nil address = options[:address] || nil if options[:lat] && options[:long] "<iframe src='https://maps.google.com/maps?q=#{lat},#{long}&output=embed' frameborder='0' style='border:0' width='#{width}' height='#{height}' allowfullscreen></iframe>" elsif options[:address] "<iframe src='https://maps.google.com/maps?q=#{prepare_address(address)}&output=embed' frameborder='0' style='border:0' width='#{width}' height='#{height}' allowfullscreen></iframe>" else "latitude, longitude or address not found. See documentation" end end def prepare_address(address) address.gsub!(',', '%2C') address.gsub!(' ', '%20') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
google_maps_rails-1.1.0 | lib/google_maps_rails/view_helpers.rb |