ProMotion-map 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8240e335c3b662a901157fbb77f9ebb3e2e687db
4
- data.tar.gz: c56b64500694327784914a24deed09373615ccb9
3
+ metadata.gz: 35f4a8eac3b35aab4e6ce647f13b70067874101f
4
+ data.tar.gz: a3c5d1fb7fadb59a956ea90d7125ec060071df63
5
5
  SHA512:
6
- metadata.gz: bfbd94ade841e4def1627d3c54f96e2a81b3d1967d24652efc19e2ee3e0a69e6374d1870d7e0561ec9f8f101a70e1f87de463d7247cb66bc42a7307123939592
7
- data.tar.gz: fb25b102018267b8ef5a57081c1e59fcd869f3f5435543546a3f1486ce67b38fa56d67a777bf431b1ef4247a3546afea5c54abef9d39fd4461981f7b6cac3ef1
6
+ metadata.gz: 1de93a95d1294c9d1a2c6ed575c4f381835746a5674790a0883fd2ad8bc0de53ad6c5986ba1441a4519def05c5bd231c1e5ff7f6641860937ca0bb5a562eb849
7
+ data.tar.gz: 0cf359ef14f0c4978c45f13545d18db814ab9b1f5440bd55b2b3cb0227c4bd9ed6ba03d3f5119b197a7b6d4b53d4fe81a9d7a802efa5834b1fa31a5b6b8b285a
data/README.md CHANGED
@@ -218,9 +218,32 @@ end
218
218
 
219
219
  ---
220
220
 
221
+ ### CocoaTouch Property Convenience Methods
222
+
223
+ `MKMapView` contains multiple property setters and getters that can be accessed in a more ruby-like syntax:
224
+
225
+ ```ruby
226
+ type # Returns a MKMapType
227
+ type = (MKMapType)new_type
228
+
229
+ zoom_enabled?
230
+ zoom_enabled = (bool)enabled
231
+
232
+ scroll_enabled?
233
+ scroll_enabled = (bool)enabled
234
+
235
+ pitch_enabled?
236
+ pitch_enabled = (bool)enabled
237
+
238
+ rotate_enabled?
239
+ rotate_enabled = (bool)enabled
240
+ ```
241
+
242
+ ---
243
+
221
244
  ### Accessors
222
245
 
223
- #### mapview
246
+ #### `map` or `mapview`
224
247
 
225
248
  Reference to the created UIMapView.
226
249
 
@@ -1,12 +1,10 @@
1
1
  module ProMotion
2
2
  module MapScreenModule
3
- attr_accessor :mapview
4
3
 
5
4
  def screen_setup
6
- self.mapview ||= add MKMapView.new, {
7
- frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height),
8
- delegate: self
9
- }
5
+ self.view = nil
6
+ self.view = MKMapView.alloc.initWithFrame(self.view.bounds)
7
+ self.view.delegate = self
10
8
 
11
9
  check_annotation_data
12
10
  @promotion_annotation_data = []
@@ -28,11 +26,12 @@ module ProMotion
28
26
  end
29
27
 
30
28
  def map
31
- self.mapview
29
+ self.view
32
30
  end
31
+ alias_method :mapview, :map
33
32
 
34
33
  def center
35
- self.mapview.centerCoordinate
34
+ self.view.centerCoordinate
36
35
  end
37
36
 
38
37
  def center=(params={})
@@ -41,7 +40,7 @@ module ProMotion
41
40
  params[:animated] ||= true
42
41
 
43
42
  # Set the new region
44
- self.mapview.setCenterCoordinate(
43
+ self.view.setCenterCoordinate(
45
44
  CLLocationCoordinate2D.new(params[:latitude], params[:longitude]),
46
45
  animated:params[:animated]
47
46
  )
@@ -56,15 +55,15 @@ module ProMotion
56
55
  end
57
56
 
58
57
  def set_show_user_location(show)
59
- self.mapview.showsUserLocation = show
58
+ self.view.showsUserLocation = show
60
59
  end
61
60
 
62
61
  def showing_user_location?
63
- self.mapview.showsUserLocation
62
+ self.view.showsUserLocation
64
63
  end
65
64
 
66
65
  def user_location
67
- self.mapview.userLocation.location.nil? ? nil : self.mapview.userLocation.location.coordinate
66
+ self.view.userLocation.location.nil? ? nil : self.view.userLocation.location.coordinate
68
67
  end
69
68
 
70
69
  def zoom_to_user(radius = 0.05, animated=true)
@@ -77,7 +76,7 @@ module ProMotion
77
76
  end
78
77
 
79
78
  def select_annotation(annotation, animated=true)
80
- self.mapview.selectAnnotation(annotation, animated:animated)
79
+ self.view.selectAnnotation(annotation, animated:animated)
81
80
  end
82
81
 
83
82
  def select_annotation_at(annotation_index, animated=true)
@@ -85,30 +84,30 @@ module ProMotion
85
84
  end
86
85
 
87
86
  def selected_annotations
88
- self.mapview.selectedAnnotations
87
+ self.view.selectedAnnotations
89
88
  end
90
89
 
91
90
  def deselect_annotations(animated=false)
92
91
  unless selected_annotations.nil?
93
92
  selected_annotations.each do |annotation|
94
- self.mapview.deselectAnnotation(annotation, animated:animated)
93
+ self.view.deselectAnnotation(annotation, animated:animated)
95
94
  end
96
95
  end
97
96
  end
98
97
 
99
98
  def add_annotation(annotation)
100
99
  @promotion_annotation_data << MapScreenAnnotation.new(annotation)
101
- self.mapview.addAnnotation @promotion_annotation_data.last
100
+ self.view.addAnnotation @promotion_annotation_data.last
102
101
  end
103
102
 
104
103
  def add_annotations(annotations)
105
104
  @promotion_annotation_data = Array(annotations).map{|a| MapScreenAnnotation.new(a)}
106
- self.mapview.addAnnotations @promotion_annotation_data
105
+ self.view.addAnnotations @promotion_annotation_data
107
106
  end
108
107
 
109
108
  def clear_annotations
110
109
  @promotion_annotation_data.each do |a|
111
- self.mapview.removeAnnotation(a)
110
+ self.view.removeAnnotation(a)
112
111
  end
113
112
  @promotion_annotation_data = []
114
113
  end
@@ -200,13 +199,13 @@ module ProMotion
200
199
  )
201
200
 
202
201
  region = MKCoordinateRegionMake(coord, span)
203
- fits = self.mapview.regionThatFits(region);
202
+ fits = self.view.regionThatFits(region);
204
203
 
205
204
  set_region(fits, animated:animated)
206
205
  end
207
206
 
208
207
  def set_region(region, animated=true)
209
- self.mapview.setRegion(region, animated:animated)
208
+ self.view.setRegion(region, animated:animated)
210
209
  end
211
210
 
212
211
  def region(params)
@@ -242,6 +241,26 @@ module ProMotion
242
241
  end
243
242
  end
244
243
 
244
+ ########## Cocoa touch Ruby counterparts #################
245
+
246
+ def type
247
+ map.mapType
248
+ end
249
+
250
+ def type=(type)
251
+ map.mapType = type
252
+ end
253
+
254
+ %w(zoom scroll pitch rotate).each do |meth|
255
+ define_method("#{meth}_enabled?") do
256
+ map.send("is#{meth.capitalize}Enabled")
257
+ end
258
+
259
+ define_method("#{meth}_enabled=") do |argument|
260
+ map.send("#{meth}Enabled=", argument)
261
+ end
262
+ end
263
+
245
264
  module MapClassMethods
246
265
  def start_position(params={})
247
266
  @start_position_params = params
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.0
4
+ version: 0.4.1
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-09-25 00:00:00.000000000 Z
12
+ date: 2014-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ProMotion
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.2.2
103
+ rubygems_version: 2.3.0
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Adds PM::MapScreen support to ProMotion. Extracted from ProMotion.