Class: Geogov::Google

Inherits:
Object
  • Object
show all
Defined in:
lib/geogov/providers/google.rb

Instance Method Summary collapse

Instance Method Details

#dimension(l1, l2) ⇒ Object



5
6
7
# File 'lib/geogov/providers/google.rb', line 5

def dimension(l1,l2)
  "#{l1}x#{l2}"
end

#location(l1, l2) ⇒ Object



9
10
11
# File 'lib/geogov/providers/google.rb', line 9

def location(l1,l2)
  "#{l1},#{l2}"
end

#map_href(lat, lon, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/geogov/providers/google.rb', line 31

def map_href(lat,lon,options = {})
  g_options = {
    :z => options[:z] || 14,
    :ie => "UTF8",
    :q  => location(lat,lon)
  }
  if options[:marker_lat] && options[:marker_lon]
    location = location(options[:marker_lat],options[:marker_lon])
    g_options[:sll] = location
  end

  params = Geogov.hash_to_params(g_options)
  "http://maps.google.com/maps?#{params}"
end

#map_img(lat, lon, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/geogov/providers/google.rb', line 13

def map_img(lat,lon,options= {})
  g_options = {
    :zoom => options[:z] || 14,
    :size => dimension(options[:w],options[:h]),
    :center => location(lat,lon),
    :sensor => false
  }
  if options[:marker_lat] && options[:marker_lon]
    location = location(options[:marker_lat],options[:marker_lon])
    g_options[:markers] = ["color:blue",location].join("|")
  end

  params = Geogov.hash_to_params(g_options)

  "http://maps.google.com/maps/api/staticmap?#{params}"
end