Class: ProMotion::MapScreenAnnotation
- Inherits:
-
Object
- Object
- ProMotion::MapScreenAnnotation
show all
- Defined in:
- lib/ProMotion/map/map_screen_annotation.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Creates the new annotation object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 6
def initialize(params = {})
@params = params
set_defaults
if @params[:coordinate]
@params[:latitude] = @params[:coordinate].latitude
@params[:longitude] = @params[:coordinate].longitude
@coordinate = @params[:coordinate]
elsif @params[:latitude] && @params[:longitude]
@coordinate = CLLocationCoordinate2D.new(@params[:latitude], @params[:longitude])
else
PM.logger.error("You are required to specify :latitude and :longitude or :coordinate for annotations.")
nil
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 56
def method_missing(meth, *args)
if @params[meth.to_sym]
@params[meth.to_sym]
else
PM.logger.warn "The annotation parameter \"#{meth}\" does not exist on this pin."
nil
end
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
3
4
5
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 3
def params
@params
end
|
Instance Method Details
#annotation_params ⇒ Object
66
67
68
69
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 66
def annotation_params
PM.logger.warn("annotation.annotation_params is deprecated and will be removed soon. Please use annotation.params instead.")
@params
end
|
#cllocation ⇒ Object
44
45
46
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 44
def cllocation
CLLocation.alloc.initWithLatitude(@params[:latitude], longitude:@params[:longitude])
end
|
#coordinate ⇒ Object
40
41
42
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 40
def coordinate
@coordinate
end
|
#set_defaults ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 22
def set_defaults
@params = {
title: "Title",
pin_color: :red,
identifier: "Annotation-#{@params[:pin_color]}-#{@params[:image]}",
show_callout: true,
animates_drop: false
}.merge(@params)
end
|
#setCoordinate(new_coordinate) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 48
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
36
37
38
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 36
def subtitle
@params[:subtitle] ||= nil
end
|
#title ⇒ Object
32
33
34
|
# File 'lib/ProMotion/map/map_screen_annotation.rb', line 32
def title
@params[:title]
end
|