ProMotion-map 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +47 -55
- data/lib/ProMotion/map/map_screen_annotation.rb +7 -5
- data/lib/ProMotion/map/map_screen_module.rb +23 -11
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8240e335c3b662a901157fbb77f9ebb3e2e687db
|
4
|
+
data.tar.gz: c56b64500694327784914a24deed09373615ccb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfbd94ade841e4def1627d3c54f96e2a81b3d1967d24652efc19e2ee3e0a69e6374d1870d7e0561ec9f8f101a70e1f87de463d7247cb66bc42a7307123939592
|
7
|
+
data.tar.gz: fb25b102018267b8ef5a57081c1e59fcd869f3f5435543546a3f1486ce67b38fa56d67a777bf431b1ef4247a3546afea5c54abef9d39fd4461981f7b6cac3ef1
|
data/README.md
CHANGED
@@ -22,46 +22,51 @@ class MyMapScreen < PM::MapScreen
|
|
22
22
|
title "My Map"
|
23
23
|
start_position latitude: 35.090648651123, longitude: -82.965972900391, radius: 4
|
24
24
|
|
25
|
-
def on_appear
|
26
|
-
update_annotation_data
|
27
|
-
end
|
28
|
-
|
29
25
|
def annotation_data
|
30
26
|
[{
|
31
27
|
longitude: -82.965972900391,
|
32
28
|
latitude: 35.090648651123,
|
33
29
|
title: "Rainbow Falls",
|
34
|
-
subtitle: "Nantahala National Forest"
|
30
|
+
subtitle: "Nantahala National Forest",
|
31
|
+
action: :show_forest
|
35
32
|
},{
|
36
33
|
longitude: -82.966093558105,
|
37
34
|
latitude: 35.092520895652,
|
38
35
|
title: "Turtleback Falls",
|
39
|
-
subtitle: "Nantahala National Forest"
|
36
|
+
subtitle: "Nantahala National Forest",
|
37
|
+
action: :show_forest
|
40
38
|
},{
|
41
39
|
longitude: -82.95916,
|
42
40
|
latitude: 35.07496,
|
43
|
-
title: "Windy Falls"
|
41
|
+
title: "Windy Falls",
|
42
|
+
action: :show_forest
|
44
43
|
},{
|
45
44
|
longitude: -82.943031505056,
|
46
45
|
latitude: 35.102516828489,
|
47
46
|
title: "Upper Bearwallow Falls",
|
48
|
-
subtitle: "Gorges State Park"
|
47
|
+
subtitle: "Gorges State Park",
|
48
|
+
action: :show_forest
|
49
49
|
},{
|
50
50
|
longitude: -82.956244328014,
|
51
51
|
latitude: 35.085548421623,
|
52
52
|
title: "Stairway Falls",
|
53
53
|
subtitle: "Gorges State Park",
|
54
|
-
your_param: "CustomWhatever"
|
54
|
+
your_param: "CustomWhatever",
|
55
|
+
action: :show_forest
|
55
56
|
}, {
|
56
57
|
longitude: -82.965972900391,
|
57
58
|
latitude: 35.090648651123,
|
58
59
|
title: "Rainbow Falls",
|
59
60
|
subtitle: "Nantahala National Forest",
|
60
|
-
image: UIImage.imageNamed("custom-pin")
|
61
|
+
image: UIImage.imageNamed("custom-pin"),
|
62
|
+
action: :show_forest
|
61
63
|
}]
|
62
64
|
end
|
63
65
|
|
64
|
-
|
66
|
+
def show_forest
|
67
|
+
selected = selected_annotations.first
|
68
|
+
# Do something with the selected annotation.
|
69
|
+
end
|
65
70
|
end
|
66
71
|
```
|
67
72
|
|
@@ -82,54 +87,19 @@ end
|
|
82
87
|
|
83
88
|
Method that is called to get the map's annotation data and build the map. If you do not want any annotations, simply return an empty array.
|
84
89
|
|
85
|
-
```ruby
|
86
|
-
def annotation_data
|
87
|
-
[{
|
88
|
-
longitude: -82.965972900391,
|
89
|
-
latitude: 35.090648651123,
|
90
|
-
title: "Rainbow Falls",
|
91
|
-
subtitle: "Nantahala National Forest"
|
92
|
-
},{
|
93
|
-
longitude: -82.965972900391,
|
94
|
-
latitude: 35.090648651123,
|
95
|
-
title: "Rainbow Falls",
|
96
|
-
subtitle: "Nantahala National Forest",
|
97
|
-
image: "custom-pin" # Use your own custom image. It will be converted to a UIImage automatically.
|
98
|
-
},{
|
99
|
-
longitude: -82.966093558105,
|
100
|
-
latitude: 35.092520895652,
|
101
|
-
title: "Turtleback Falls",
|
102
|
-
subtitle: "Nantahala National Forest"
|
103
|
-
},{
|
104
|
-
longitude: -82.95916,
|
105
|
-
latitude: 35.07496,
|
106
|
-
title: "Windy Falls"
|
107
|
-
},{
|
108
|
-
longitude: -82.943031505056,
|
109
|
-
latitude: 35.102516828489,
|
110
|
-
title: "Upper Bearwallow Falls",
|
111
|
-
subtitle: "Gorges State Park"
|
112
|
-
},{
|
113
|
-
longitude: -82.956244328014,
|
114
|
-
latitude: 35.085548421623,
|
115
|
-
title: "Stairway Falls",
|
116
|
-
subtitle: "Gorges State Park",
|
117
|
-
your_param: "CustomWahtever"
|
118
|
-
}]
|
119
|
-
end
|
120
|
-
```
|
121
|
-
|
122
90
|
All possible properties:
|
123
91
|
|
124
92
|
```ruby
|
125
93
|
{
|
126
|
-
longitude: -82.956244328014,
|
127
|
-
latitude: 35.085548421623,
|
128
|
-
title: "Stairway Falls",
|
94
|
+
longitude: -82.956244328014, # REQUIRED
|
95
|
+
latitude: 35.085548421623, # REQUIRED
|
96
|
+
title: "Stairway Falls", # REQUIRED
|
129
97
|
subtitle: "Gorges State Park",
|
130
98
|
image: "my_custom_image",
|
131
99
|
left_accessory: my_button,
|
132
|
-
right_accessory: my_other_button
|
100
|
+
right_accessory: my_other_button,
|
101
|
+
action: :my_action, # Overrides :right_accessory
|
102
|
+
action_button_type: UIButtonTypeContactAdd # Defaults to UIButtonTypeDetailDisclosure
|
133
103
|
}
|
134
104
|
```
|
135
105
|
|
@@ -139,12 +109,18 @@ Use `:image` to specify a custom image. Pass in a string to conserve memory and
|
|
139
109
|
|
140
110
|
Use `:left_accessory` and `:right_accessory` to specify a custom accessory, like a button.
|
141
111
|
|
142
|
-
You can access annotation data you've arbitrarily stored in the hash by calling `annotation_instance.
|
112
|
+
You can access annotation data you've arbitrarily stored in the hash by calling `annotation_instance.params[:your_param]`.
|
113
|
+
|
114
|
+
The `:action` parameter specifies a method that should be run when the detail button is tapped on the annotation. It automatically adds a `UIButtonTypeDetailDisclosure` button to the `:left_accessory`. In your method you can find out which annotation's accessory was tapped by calling `selected_annotations.first`.
|
143
115
|
|
144
116
|
#### update_annotation_data
|
145
117
|
|
146
118
|
Forces a reload of all the annotations
|
147
119
|
|
120
|
+
#### annotations
|
121
|
+
|
122
|
+
Returns an array of all the annotations.
|
123
|
+
|
148
124
|
#### center
|
149
125
|
|
150
126
|
Returns a `CLLocation2D` instance with the center coordinates of the map.
|
@@ -153,9 +129,25 @@ Returns a `CLLocation2D` instance with the center coordinates of the map.
|
|
153
129
|
|
154
130
|
Sets the center of the map. `animated` property defaults to `true`.
|
155
131
|
|
156
|
-
####
|
132
|
+
#### show_user_location
|
157
133
|
|
158
|
-
|
134
|
+
Shows the user's location on the map.
|
135
|
+
|
136
|
+
#### hide_user_location
|
137
|
+
|
138
|
+
Hides the user's location on the map.
|
139
|
+
|
140
|
+
#### showing_user_location?
|
141
|
+
|
142
|
+
Returns a `Boolean` of whether or not the map view is currently showing the user's location.
|
143
|
+
|
144
|
+
#### user_location
|
145
|
+
|
146
|
+
Returns a `CLLocation2D` object of the user's location or `nil` if the user location is not being tracked
|
147
|
+
|
148
|
+
#### zoom_to_user(radius = 0.05, animated=true)
|
149
|
+
|
150
|
+
Zooms to the user's location. If the user's location is not currently being shown on the map, it will show it first. `radius` is a `CLLocationDegrees` of the latitude and longitude deltas. _See Apple documentation for `MKCoordinateSpan` for more information._
|
159
151
|
|
160
152
|
#### select_annotation(annotation, animated=true)
|
161
153
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module ProMotion
|
2
2
|
class MapScreenAnnotation
|
3
|
+
attr_reader :params
|
3
4
|
|
4
5
|
# Creates the new annotation object
|
5
6
|
def initialize(params = {})
|
@@ -47,11 +48,6 @@ module ProMotion
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
# Allows for retrieving your own custom values on the annotation
|
51
|
-
def annotation_params
|
52
|
-
@params
|
53
|
-
end
|
54
|
-
|
55
51
|
def method_missing(meth, *args)
|
56
52
|
if @params[meth.to_sym]
|
57
53
|
@params[meth.to_sym]
|
@@ -61,5 +57,11 @@ module ProMotion
|
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
60
|
+
# Deprecated
|
61
|
+
def annotation_params
|
62
|
+
PM.logger.warn("annotation.annotation_params is deprecated and will be removed soon. Please use annotation.params instead.")
|
63
|
+
@params
|
64
|
+
end
|
65
|
+
|
64
66
|
end
|
65
67
|
end
|
@@ -38,7 +38,7 @@ module ProMotion
|
|
38
38
|
def center=(params={})
|
39
39
|
PM.logger.error "Missing #:latitude property in call to #center=." unless params[:latitude]
|
40
40
|
PM.logger.error "Missing #:longitude property in call to #center=." unless params[:longitude]
|
41
|
-
params[:animated]
|
41
|
+
params[:animated] ||= true
|
42
42
|
|
43
43
|
# Set the new region
|
44
44
|
self.mapview.setCenterCoordinate(
|
@@ -116,26 +116,38 @@ module ProMotion
|
|
116
116
|
def annotation_view(map_view, annotation)
|
117
117
|
return if annotation.is_a? MKUserLocation
|
118
118
|
|
119
|
-
|
119
|
+
params = annotation.params
|
120
|
+
|
121
|
+
identifier = params[:identifier]
|
120
122
|
if view = map_view.dequeueReusableAnnotationViewWithIdentifier(identifier)
|
121
123
|
view.annotation = annotation
|
122
124
|
else
|
123
125
|
# Set the pin properties
|
124
|
-
if
|
126
|
+
if params[:image]
|
125
127
|
view = MKAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:identifier)
|
126
128
|
else
|
127
129
|
view = MKPinAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:identifier)
|
128
130
|
end
|
129
131
|
end
|
130
|
-
view.image =
|
131
|
-
view.animatesDrop =
|
132
|
-
view.pinColor =
|
133
|
-
view.canShowCallout =
|
134
|
-
|
135
|
-
|
132
|
+
view.image = params[:image] if view.respond_to?("image=") && params[:image]
|
133
|
+
view.animatesDrop = params[:animates_drop] if view.respond_to?("animatesDrop=")
|
134
|
+
view.pinColor = params[:pin_color] if view.respond_to?("pinColor=")
|
135
|
+
view.canShowCallout = params[:show_callout] if view.respond_to?("canShowCallout=")
|
136
|
+
|
137
|
+
if params[:left_accessory]
|
138
|
+
view.leftCalloutAccessoryView = params[:left_accessory]
|
139
|
+
end
|
140
|
+
if params[:right_accessory]
|
141
|
+
view.rightCalloutAccessoryView = params[:right_accessory]
|
136
142
|
end
|
137
|
-
|
138
|
-
|
143
|
+
|
144
|
+
if params[:action]
|
145
|
+
button_type = params[:action_button_type] || UIButtonTypeDetailDisclosure
|
146
|
+
|
147
|
+
action_button = UIButton.buttonWithType(button_type)
|
148
|
+
action_button.addTarget(self, action: params[:action], forControlEvents:UIControlEventTouchUpInside)
|
149
|
+
|
150
|
+
view.rightCalloutAccessoryView = action_button
|
139
151
|
end
|
140
152
|
view
|
141
153
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion-map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickert
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ProMotion
|
@@ -105,4 +105,3 @@ signing_key:
|
|
105
105
|
specification_version: 4
|
106
106
|
summary: Adds PM::MapScreen support to ProMotion. Extracted from ProMotion.
|
107
107
|
test_files: []
|
108
|
-
has_rdoc:
|