ProMotion-map 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64053c678871e7edbe5731c9627fdb527b71ab54
4
- data.tar.gz: 3aef92fbedc6f4f9fb4a4adf459184ffb060d593
3
+ metadata.gz: edd818066a99f0ab90ba913a19ea359e555b3b4f
4
+ data.tar.gz: cffef6478e20af2f336d449acd51385bb9eafdc0
5
5
  SHA512:
6
- metadata.gz: 55bfb725bcbba98691a3848fb92fed298813560c9d773ebe2f58903bd3e723d856e922415346a5e2a1663180ce5fb882f198396052b081eeb6ac06badb7e80a7
7
- data.tar.gz: 1e3aec7ee94d35c82c216f8abcd1ba0cd05b881c0b449df2632481fa87753dc10f6c17f318f7fa6f845abbad2bb09c8ecd102ad1ea8b6546ac0032d2dc3e48b9
6
+ metadata.gz: 10066d1c96a8dec11416aefc77d766cf8a484c5bf279f728f0bbe02eede4a57835ebc05f0719d2ddedb7d67ca3d7dfac3aae4ac1cd342ff92bbba7cb3fabe134
7
+ data.tar.gz: 2451e7c00956b3109b5fd8caa7317b6e9f457fabf1d2f476ad81ce85e2dfaf11fa2aa8d92124d5d7193ae1c0480f6cac78cd66402f2261bc995df8a35b1051b8
data/README.md CHANGED
@@ -177,9 +177,9 @@ Adds more than one annotation at a time to the map.
177
177
 
178
178
  Removes all annotations from the `MapScreen`.
179
179
 
180
- #### zoom_to_fit_annotations(animated=true)
180
+ #### zoom_to_fit_annotations({animated:true, include_user:false})
181
181
 
182
- Changes the zoom and center point of the `MapScreen` to fit all the annotations.
182
+ Changes the zoom and center point of the `MapScreen` to fit all the annotations. Passing `include_user` as `true` will cause the zoom to not only include the annotations from `annotation_data` but also the user pin in the zoom region calculation.
183
183
 
184
184
  #### set_region(region, animated=true)
185
185
 
@@ -67,7 +67,11 @@ module ProMotion
67
67
  end
68
68
 
69
69
  def user_location
70
- self.view.userLocation.location.nil? ? nil : self.view.userLocation.location.coordinate
70
+ user_annotation.nil? ? nil : user_annotation.coordinate
71
+ end
72
+
73
+ def user_annotation
74
+ self.view.userLocation.location.nil? ? nil : self.view.userLocation.location
71
75
  end
72
76
 
73
77
  def zoom_to_user(radius = 0.05, animated=true)
@@ -174,16 +178,22 @@ module ProMotion
174
178
  end
175
179
 
176
180
  # TODO: Why is this so complex?
177
- def zoom_to_fit_annotations(animated=true)
181
+ def zoom_to_fit_annotations(args={})
182
+ # Preserve backwards compatibility
183
+ args = {animated: args} if args == true || args == false
184
+ args = {animated: true, include_user: false}.merge(args)
185
+
186
+ ann = args[:include_user] ? (annotations + [user_annotation]).compact : annotations
187
+
178
188
  #Don't attempt the rezoom of there are no pins
179
- return if annotations.count == 0
189
+ return if ann.count == 0
180
190
 
181
191
  #Set some crazy boundaries
182
192
  topLeft = CLLocationCoordinate2D.new(-90, 180)
183
193
  bottomRight = CLLocationCoordinate2D.new(90, -180)
184
194
 
185
195
  #Find the bounds of the pins
186
- annotations.each do |a|
196
+ ann.each do |a|
187
197
  topLeft.longitude = [topLeft.longitude, a.coordinate.longitude].min
188
198
  topLeft.latitude = [topLeft.latitude, a.coordinate.latitude].max
189
199
  bottomRight.longitude = [bottomRight.longitude, a.coordinate.longitude].max
@@ -203,9 +213,9 @@ module ProMotion
203
213
  )
204
214
 
205
215
  region = MKCoordinateRegionMake(coord, span)
206
- fits = self.view.regionThatFits(region);
216
+ fits = self.view.regionThatFits(region)
207
217
 
208
- set_region(fits, animated:animated)
218
+ set_region(fits, animated: args[:animated])
209
219
  end
210
220
 
211
221
  def set_region(region, animated=true)
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.2
4
+ version: 0.5.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-10-10 00:00:00.000000000 Z
12
+ date: 2014-11-18 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.3.0
103
+ rubygems_version: 2.2.0
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Adds PM::MapScreen support to ProMotion. Extracted from ProMotion.