Sha256: eacc7ee5deb7be11963b23a8bd45ee85c165571e4b1ee6fa9c2227128d1ca35a
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'uri' module Voom module Presenters module DSL module Components class GoogleMap < Base attr_reader :url, :google_api_key, :height, :width def initialize(**attribs_, &block) super(type: :google_map, **attribs_, &block) @address = attribs.delete(:address) @latitude = attribs.delete(:latitude) @longitude = attribs.delete(:longitude) @width = attribs.delete(:width) { 640 } @height = attribs.delete(:height) { 640 } @zoom = attribs.delete(:zoom) { 14 } @scale = attribs.delete(:scale) { 1 } @google_api_key = attribs.delete(:google_api_key) { ENV['GOOGLE_API_KEY'] } @url = build_static_map_image_url end private def build_static_map_image_url return @img_url if locked? @img_url = "https://maps.googleapis.com/maps/api/staticmap?center=#{query_string}&zoom=#{@zoom}&scale=#{@scale}&size=#{@width}x#{@height}&markers=|#{query_string}&key=#{@google_api_key}" end def query_string return "#{@latitude},#{@longitude}" if @latitude && @longitude URI.escape(@address) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
voom-presenters-0.2.0 | lib/voom/presenters/dsl/components/google_map.rb |