Class: StaticGmaps::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/static_gmaps.rb

Constant Summary collapse

DEFAULT_CENTER =
[ 0, 0 ]
DEFAULT_ZOOM =
1
DEFAULT_SIZE =
[ 500, 400 ]
DEFAULT_MAP_TYPE =
:roadmap
DEFAULT_KEY =
'ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Map

Returns a new instance of Map.



41
42
43
44
45
46
47
# File 'lib/static_gmaps.rb', line 41

def initialize(options = {})
  self.center   = options[:center]   || DEFAULT_CENTER
  self.zoom     = options[:zoom]     || DEFAULT_ZOOM
  self.size     = options[:size]     || DEFAULT_SIZE
  self.map_type = options[:map_type] || DEFAULT_MAP_TYPE
  self.key      = options[:key]      || DEFAULT_KEY
end

Instance Attribute Details

#centerObject

Returns the value of attribute center.



35
36
37
# File 'lib/static_gmaps.rb', line 35

def center
  @center
end

#keyObject

Returns the value of attribute key.



35
36
37
# File 'lib/static_gmaps.rb', line 35

def key
  @key
end

#map_typeObject

Returns the value of attribute map_type.



35
36
37
# File 'lib/static_gmaps.rb', line 35

def map_type
  @map_type
end

#sizeObject

Returns the value of attribute size.



35
36
37
# File 'lib/static_gmaps.rb', line 35

def size
  @size
end

#zoomObject

Returns the value of attribute zoom.



35
36
37
# File 'lib/static_gmaps.rb', line 35

def zoom
  @zoom
end

Instance Method Details

#heightObject



53
54
55
# File 'lib/static_gmaps.rb', line 53

def height
  size[1]
end

#to_blobObject



61
62
63
64
# File 'lib/static_gmaps.rb', line 61

def to_blob
  fetch
  return @blob
end

#urlObject



57
58
59
# File 'lib/static_gmaps.rb', line 57

def url
  return "http://maps.google.com/staticmap?center=#{center[0]},#{center[1]}&zoom=#{zoom}&size=#{size[0]}x#{size[1]}&map_type=#{map_type}&key=#{key}"
end

#widthObject



49
50
51
# File 'lib/static_gmaps.rb', line 49

def width
  size[0]
end