Class: Smappy::Location
- Inherits:
-
Object
- Object
- Smappy::Location
- Defined in:
- lib/smappy/location.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
Instance Method Summary collapse
-
#initialize(latitude, longitude) ⇒ Location
constructor
A new instance of Location.
- #position_on_map(map) ⇒ Object
- #position_on_tile(tile) ⇒ Object
- #to_tile(options = {}) ⇒ Object
Constructor Details
#initialize(latitude, longitude) ⇒ Location
Returns a new instance of Location.
5 6 7 8 |
# File 'lib/smappy/location.rb', line 5 def initialize(latitude, longitude) self.latitude = latitude self.longitude = longitude end |
Instance Attribute Details
#latitude ⇒ Object
Returns the value of attribute latitude.
3 4 5 |
# File 'lib/smappy/location.rb', line 3 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
3 4 5 |
# File 'lib/smappy/location.rb', line 3 def longitude @longitude end |
Instance Method Details
#position_on_map(map) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/smappy/location.rb', line 17 def position_on_map(map) tile = to_tile(zoomlevel: map.zoomlevel) x1, y1 = position_on_tile(tile) x2, y2 = tile.position_on_map(map) [x1 + x2, y1 + y2] end |