Class: Geogov::OpenStreetMap

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

Instance Method Summary collapse

Constructor Details

#initialize(url = "http://ojw.dev.openstreetmap.org") ⇒ OpenStreetMap

Returns a new instance of OpenStreetMap.



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

def initialize(url = "http://ojw.dev.openstreetmap.org")
  @url = url
end

Instance Method Details

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



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

def map_href(lat,long,options = {})
  options = {
    :zoom => options[:z] || 14,
    :lat => lat,
    :lon => long,
    :layers => "M"
  }.merge(options)

  if options[:marker_lat] && options[:marker_lon]
    options[:mlat0] = options.delete(:marker_lat)
    options[:mlon0] = options.delete(:marker_lon)
  end

  params = Geogov.hash_to_params(options)

  "http://www.openstreetmap.org/?#{params}"
end

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



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

def map_img(lat,long,options = {})
  options = {
    :w => 200,
    :h => 200,
    :z => 14,
    :mode => "export",
    :lat => lat,
    :lon => long,
    :show => 1
  }.merge(options)

  if options[:marker_lat] && options[:marker_lon]
    options[:mlat0] = options.delete(:marker_lat)
    options[:mlon0] = options.delete(:marker_lon)
  end

  params = Geogov.hash_to_params(options)

  "#{@url}/StaticMap?#{params}"
end