Class: BHM::GoogleMaps::Builder
- Inherits:
-
Object
- Object
- BHM::GoogleMaps::Builder
- Defined in:
- lib/bhm/google_maps/builder.rb
Defined Under Namespace
Classes: BasicMarker
Instance Method Summary collapse
- #address_as_string ⇒ Object
- #build_container ⇒ Object
- #build_static_map(marker_options) ⇒ Object
-
#initialize(template, address, options) ⇒ Builder
constructor
A new instance of Builder.
- #ll_pair ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(template, address, options) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 10 |
# File 'lib/bhm/google_maps/builder.rb', line 6 def initialize(template, address, ) @template = template @address = address @options = .symbolize_keys end |
Instance Method Details
#address_as_string ⇒ Object
44 45 46 |
# File 'lib/bhm/google_maps/builder.rb', line 44 def address_as_string BHM::GoogleMaps.address_to_s_proc.call(@address) end |
#build_container ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bhm/google_maps/builder.rb', line 20 def build_container = @options[:marker] || {} ll = self.ll_pair address = self.address_as_string = {} ['data-latitude'] = ll[0] ['data-longitude'] = ll[1] [:title] ||= address .each_pair do |k, v| ["data-marker-#{k.to_s.dasherize}"] = v end default_css_class = "#{BHM::GoogleMaps.container_class} #{BHM::GoogleMaps.static_map_class}" = (, :class => default_css_class) @template.content_tag(:div, build_static_map(), ) end |
#build_static_map(marker_options) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/bhm/google_maps/builder.rb', line 12 def build_static_map() ll = self.ll_pair address = self.address_as_string address_proxy = BasicMarker.new(address, ll[0], ll[1]) static_map_url = StaticMap.for_address(address_proxy, .merge(@options[:static_map] || {})) @template.image_tag(static_map_url, {:alt => address}.reverse_merge(@options[:static_map_html] || {})) end |
#ll_pair ⇒ Object
40 41 42 |
# File 'lib/bhm/google_maps/builder.rb', line 40 def ll_pair BHM::GoogleMaps.address_to_lat_lng_proc.call(@address) end |
#to_html ⇒ Object
36 37 38 |
# File 'lib/bhm/google_maps/builder.rb', line 36 def to_html @to_html ||= build_container end |