Class: ProMotion::MapScreenAnnotation
- Inherits:
-
Object
- Object
- ProMotion::MapScreenAnnotation
- Defined in:
- lib/ProMotion/map/map_screen_annotation.rb
Instance Method Summary collapse
-
#annotation_params ⇒ Object
Allows for retrieving your own custom values on the annotation.
- #cllocation ⇒ Object
- #coordinate ⇒ Object
-
#initialize(params = {}) ⇒ MapScreenAnnotation
constructor
Creates the new crime object.
- #set_defaults ⇒ Object
- #setCoordinate(new_coordinate) ⇒ Object
- #subtitle ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ MapScreenAnnotation
Creates the new crime object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 5 def initialize(params = {}) @params = params set_defaults unless @params[:latitude] && @params[:longitude] PM.logger.error("You are required to specify :latitude and :longitude for annotations.") return nil end @coordinate = CLLocationCoordinate2D.new(@params[:latitude], @params[:longitude]) end |
Instance Method Details
#annotation_params ⇒ Object
Allows for retrieving your own custom values on the annotation
51 52 53 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 51 def annotation_params @params end |
#cllocation ⇒ Object
38 39 40 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 38 def cllocation CLLocation.alloc.initWithLatitude(@params[:latitude], longitude:@params[:longitude]) end |
#coordinate ⇒ Object
34 35 36 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 34 def coordinate @coordinate end |
#set_defaults ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 16 def set_defaults @params = { title: "Title", pin_color: MKPinAnnotationColorRed, identifier: "Annotation-#{@params[:pin_color]}", show_callout: true, animates_drop: false }.merge(@params) end |
#setCoordinate(new_coordinate) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 42 def setCoordinate(new_coordinate); if new_coordinate.is_a? Hash @coordinate = CLLocationCoordinate2D.new(new_coordinate[:latitude], new_coordinate[:longitude]) else @coordinate = new_coordinate end end |
#subtitle ⇒ Object
30 31 32 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 30 def subtitle @params[:subtitle] ||= nil end |
#title ⇒ Object
26 27 28 |
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 26 def title @params[:title] end |