Class: StaticGmaps::Map
- Inherits:
-
Object
- Object
- StaticGmaps::Map
- 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
-
#center ⇒ Object
Returns the value of attribute center.
-
#key ⇒ Object
Returns the value of attribute key.
-
#map_type ⇒ Object
Returns the value of attribute map_type.
-
#size ⇒ Object
Returns the value of attribute size.
-
#zoom ⇒ Object
Returns the value of attribute zoom.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(options = {}) ⇒ Map
constructor
A new instance of Map.
- #to_blob ⇒ Object
- #url ⇒ Object
- #width ⇒ Object
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( = {}) self.center = [:center] || DEFAULT_CENTER self.zoom = [:zoom] || DEFAULT_ZOOM self.size = [:size] || DEFAULT_SIZE self.map_type = [:map_type] || DEFAULT_MAP_TYPE self.key = [:key] || DEFAULT_KEY end |
Instance Attribute Details
#center ⇒ Object
Returns the value of attribute center.
35 36 37 |
# File 'lib/static_gmaps.rb', line 35 def center @center end |
#key ⇒ Object
Returns the value of attribute key.
35 36 37 |
# File 'lib/static_gmaps.rb', line 35 def key @key end |
#map_type ⇒ Object
Returns the value of attribute map_type.
35 36 37 |
# File 'lib/static_gmaps.rb', line 35 def map_type @map_type end |
#size ⇒ Object
Returns the value of attribute size.
35 36 37 |
# File 'lib/static_gmaps.rb', line 35 def size @size end |
#zoom ⇒ Object
Returns the value of attribute zoom.
35 36 37 |
# File 'lib/static_gmaps.rb', line 35 def zoom @zoom end |
Instance Method Details
#height ⇒ Object
53 54 55 |
# File 'lib/static_gmaps.rb', line 53 def height size[1] end |
#to_blob ⇒ Object
61 62 63 64 |
# File 'lib/static_gmaps.rb', line 61 def to_blob fetch return @blob end |
#url ⇒ Object
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 |
#width ⇒ Object
49 50 51 |
# File 'lib/static_gmaps.rb', line 49 def width size[0] end |