Module: MapHelper

Defined in:
app/helpers/map_helper.rb

Instance Method Summary collapse

Instance Method Details

#map(locations, init = {zoom: 12}) ⇒ Object


22
23
24
25
26
27
28
29
# File 'app/helpers/map_helper.rb', line 22

def map(locations, init = {zoom: 12})
  init = Whitelabel[:location].merge(init)
  data = {
    map:  locations.to_json,
    init: init.to_json,
  }
   :div, '', class: 'map_canvas', data: data
end

#single_map(location, init = {zoom: 14}) ⇒ Object


14
15
16
17
18
19
20
# File 'app/helpers/map_helper.rb', line 14

def single_map(location, init = {zoom: 14})
  data = {
    map:  Array(location).to_json,
    init: location.attributes.merge(init).to_json,
  }
   :div, '', class: 'map_canvas', data: data
end

#static_map(*locations) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/map_helper.rb', line 2

def static_map(*locations)
  options = {
    zoom:     12,
    sensor:   false,
    key:      "AIzaSyBskJCTxAU9UbH3qijy46oNtZ1-4ad14PM",
  }
  params =  options.collect{ |k,v| "#{k}=#{v}" }
  params += locations.map { |l| "markers=#{l.lat},#{l.long}" }
  url = "http://maps.googleapis.com/maps/api/staticmap"
  "#{url}?#{URI.escape(params.join('&'))}"
end