Module: BHM::GoogleMaps::Helper

Defined in:
lib/bhm/google_maps/helper.rb

Instance Method Summary collapse

Instance Method Details

#draw_map_of(address, options = {}) ⇒ Object



19
20
21
22
# File 'lib/bhm/google_maps/helper.rb', line 19

def draw_map_of(address, options = {})
  use_gmaps_js
  BHM::GoogleMaps::Builder.new(self, address, options).to_html
end

#google_maps_url(sensor = false) ⇒ Object



9
10
11
# File 'lib/bhm/google_maps/helper.rb', line 9

def google_maps_url(sensor = false)
  "http://maps.google.com/maps/api/js?sensor=#{sensor}"
end

#static_map_of_address(address, options = {}) ⇒ Object

Returns an image map with a single address plotted on a single static google map.



31
32
33
# File 'lib/bhm/google_maps/helper.rb', line 31

def static_map_of_address(address, options = {})
  image_tag(BHM::GoogleMaps::StaticMap.for_address(address, options), :alt => BHM::GoogleMaps.address_to_s_proc(address))
end

#static_map_of_addresses(addresses, options = {}) ⇒ Object

Given an array of addresses, will return an image an image tag with a static google map plotting those points.



26
27
28
# File 'lib/bhm/google_maps/helper.rb', line 26

def static_map_of_addresses(addresses, options = {})
  image_tag(BHM::GoogleMaps::StaticMap.for_addresses(addresses, options), :alt => "#{pluralize addresses.size, "address"} plotted on a map")
end

#use_gmaps_jsObject



13
14
15
16
17
# File 'lib/bhm/google_maps/helper.rb', line 13

def use_gmaps_js
  return if using_gmaps_js?
  BHM::GoogleMaps.include_js_proc.call(self)
  @using_gmaps_js = true
end

#using_gmaps_js?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/bhm/google_maps/helper.rb', line 5

def using_gmaps_js?
  instance_variable_defined?(:@using_gmaps_js) && !!@using_gmaps_js
end