Sha256: e45a656653f9e69df5bc274535933eeadcab9fcb7b001a01b319d41d33f11d8a
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'uri' module Coprl module Presenters module Plugins module GoogleMaps class GoogleMap < DSL::Components::EventBase 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 expand! 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coprl-3.0.0.beta.2 | lib/coprl/presenters/plugins/google_maps/google_map.rb |
coprl-3.0.0.beta.1 | lib/coprl/presenters/plugins/google_maps/google_map.rb |