ProMotion-map 0.1.0 → 0.2.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: 730e656d5fad2888c9705a25a3344e086c3db6ff
4
- data.tar.gz: d6d4d53d49f436970603a88d2c78110699900119
3
+ metadata.gz: 70a9a106deb0932c6dc966bca323dee405e063ee
4
+ data.tar.gz: a4468f012c886d110310f671c8ecccaca1089862
5
5
  SHA512:
6
- metadata.gz: 6fed3989bcade0436a2ee3d5f72f695de72ba733bf846917ab9c4a76cab8b12805eab9c8754cacd353e4b2596f6f86f988b4446f0a0ec1221b72c3399be820a3
7
- data.tar.gz: e583ef3a2a88df469cbc54c8df5a507508698fd6c15151f9023590120c0b890a6d8e29755eda88a57ce8fb2cd4932ca0d82a527af728f7615ad5a6453797b8a5
6
+ metadata.gz: 403aeea9f5b7aeb3e6cf7c51381399f6fa63a2461486c79dae772e21134c4f3b2733279cde1d761434b5ec9bc267b793180b431ee42035635753da2037688dcc
7
+ data.tar.gz: 075ebca199dfcfffb645195d474a362339b247fd0a5b346f2fbd34637065b2478b9a11c444adfbe0c77cf623c7a2ec0dd09e139b82bcbb4a5a9ccef7c12e703a
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ProMotion-map
2
2
 
3
- ProMotion-map is push notification support, extracted from the
3
+ [![Gem Version](https://badge.fury.io/rb/ProMotion-map.svg)](http://badge.fury.io/rb/ProMotion-map) [![Build Status](https://travis-ci.org/clearsightstudio/ProMotion-map.svg)](https://travis-ci.org/clearsightstudio/ProMotion-map) [![Code Climate](https://codeclimate.com/github/clearsightstudio/ProMotion-map.png)](https://codeclimate.com/github/clearsightstudio/ProMotion-map)
4
+
5
+ ProMotion-map provides a PM::MapScreen, extracted from the
4
6
  popular RubyMotion gem [ProMotion](https://github.com/clearsightstudio/ProMotion).
5
7
 
6
8
  ## Installation
@@ -19,11 +21,11 @@ Easily create a map screen, complete with annotations.
19
21
  class MyMapScreen < PM::MapScreen
20
22
  title "My Map"
21
23
  start_position latitude: 35.090648651123, longitude: -82.965972900391, radius: 4
22
-
24
+
23
25
  def on_appear
24
26
  update_annotation_data
25
27
  end
26
-
28
+
27
29
  def annotation_data
28
30
  [{
29
31
  longitude: -82.965972900391,
@@ -59,7 +61,7 @@ class MyMapScreen < PM::MapScreen
59
61
  }]
60
62
  end
61
63
 
62
-
64
+
63
65
  end
64
66
  ```
65
67
 
@@ -77,7 +79,7 @@ end
77
79
  ### Methods
78
80
 
79
81
  #### annotation_data
80
-
82
+
81
83
  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.
82
84
 
83
85
  ```ruby
@@ -117,10 +119,26 @@ def annotation_data
117
119
  end
118
120
  ```
119
121
 
122
+ All possible properties:
123
+
124
+ ```ruby
125
+ {
126
+ longitude: -82.956244328014,
127
+ latitude: 35.085548421623,
128
+ title: "Stairway Falls",
129
+ subtitle: "Gorges State Park",
130
+ image: "my_custom_image",
131
+ left_accessory: my_button,
132
+ right_accessory: my_other_button
133
+ }
134
+ ```
135
+
120
136
  You may pass whatever properties you want in the annotation hash, but `:longitude`, `:latitude`, and `:title` are required.
121
137
 
122
138
  Use `:image` to specify a custom image. Pass in a string to conserve memory and it will be converted using `UIImage.imageNamed(your_string)`. If you pass in a `UIImage`, we'll use that, but keep in mind that there will be another unnecessary copy of the UIImage in memory.
123
139
 
140
+ Use `:left_accessory` and `:right_accessory` to specify a custom accessory, like a button.
141
+
124
142
  You can access annotation data you've arbitrarily stored in the hash by calling `annotation_instance.annotation_params[:your_param]`.
125
143
 
126
144
  #### update_annotation_data
@@ -182,7 +200,7 @@ Helper method to create an `MKCoordinateRegion`. Expects a hash in the form of:
182
200
  ```ruby
183
201
  my_region = region({
184
202
  coordinate:{
185
- latitude: 35.0906,
203
+ latitude: 35.0906,
186
204
  longitude: -82.965
187
205
  },
188
206
  # span is the latitude and longitude delta
@@ -195,7 +213,7 @@ my_region = region({
195
213
  ### Class Methods
196
214
 
197
215
  #### start_position(latitude: Float, longitude: Float, radius: Float)
198
-
216
+
199
217
  Class method to set the initial starting position of the `MapScreen`.
200
218
 
201
219
  ```ruby
data/lib/ProMotion-map.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
-
3
2
  unless defined?(Motion::Project::Config)
4
3
  raise "ProMotion-map must be required within a RubyMotion project."
5
4
  end
@@ -17,7 +17,7 @@ module ProMotion
17
17
  @params = {
18
18
  title: "Title",
19
19
  pin_color: MKPinAnnotationColorRed,
20
- identifier: "Annotation-#{@params[:pin_color] || @params[:image]}",
20
+ identifier: "Annotation-#{@params[:pin_color]}-#{@params[:image]}",
21
21
  show_callout: true,
22
22
  animates_drop: false
23
23
  }.merge(@params)
@@ -3,10 +3,8 @@ module ProMotion
3
3
  attr_accessor :mapview
4
4
 
5
5
  def screen_setup
6
- check_mapkit_included
7
6
  self.mapview ||= add MKMapView.new, {
8
7
  frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height),
9
- resize: [ :width, :height ],
10
8
  delegate: self
11
9
  }
12
10
 
@@ -20,10 +18,6 @@ module ProMotion
20
18
  update_annotation_data
21
19
  end
22
20
 
23
- def check_mapkit_included
24
- PM.logger.error "You must add MapKit and CoreLocation to your project's frameworks in the Rakefile." unless defined?(CLLocationCoordinate2D)
25
- end
26
-
27
21
  def check_annotation_data
28
22
  PM.logger.error "Missing #annotation_data method in MapScreen #{self.class.to_s}." unless self.respond_to?(:annotation_data)
29
23
  end
@@ -119,23 +113,29 @@ module ProMotion
119
113
  @promotion_annotation_data = []
120
114
  end
121
115
 
122
- def mapView(mapView, viewForAnnotation:annotation)
116
+ def annotation_view(map_view, annotation)
123
117
  return if annotation.is_a? MKUserLocation
124
118
 
125
119
  identifier = annotation.annotation_params[:identifier]
126
- if view = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
120
+ if view = map_view.dequeueReusableAnnotationViewWithIdentifier(identifier)
127
121
  view.annotation = annotation
128
122
  else
129
- #Set the pin properties
123
+ # Set the pin properties
130
124
  if annotation.annotation_params[:image]
131
125
  view = MKAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:identifier)
132
- view.image = annotation.annotation_params[:image]
133
126
  else
134
127
  view = MKPinAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:identifier)
135
- view.animatesDrop = annotation.annotation_params[:animates_drop]
136
- view.pinColor = annotation.annotation_params[:pin_color]
137
128
  end
138
- view.canShowCallout = annotation.annotation_params[:show_callout]
129
+ end
130
+ view.image = annotation.annotation_params[:image] if view.respond_to?("image=") && annotation.annotation_params[:image]
131
+ view.animatesDrop = annotation.annotation_params[:animates_drop] if view.respond_to?("animatesDrop=")
132
+ view.pinColor = annotation.annotation_params[:pin_color] if view.respond_to?("pinColor=")
133
+ view.canShowCallout = annotation.annotation_params[:show_callout] if view.respond_to?("canShowCallout=")
134
+ if annotation.annotation_params[:left_accessory]
135
+ view.leftCalloutAccessoryView = annotation.annotation_params[:left_accessory]
136
+ end
137
+ if annotation.annotation_params[:right_accessory]
138
+ view.rightCalloutAccessoryView = annotation.annotation_params[:right_accessory]
139
139
  end
140
140
  view
141
141
  end
@@ -175,7 +175,7 @@ module ProMotion
175
175
  bottomRight.latitude = [bottomRight.latitude, a.coordinate.latitude].min
176
176
  end
177
177
 
178
- #Find the bounds of all the pins and set the mapView
178
+ #Find the bounds of all the pins and set the map_view
179
179
  coord = CLLocationCoordinate2D.new(
180
180
  topLeft.latitude - (topLeft.latitude - bottomRight.latitude) * 0.5,
181
181
  topLeft.longitude + (bottomRight.longitude - topLeft.longitude) * 0.5
@@ -218,7 +218,11 @@ module ProMotion
218
218
  end
219
219
 
220
220
  ########## Cocoa touch methods #################
221
- def mapView(mapView, didUpdateUserLocation:userLocation)
221
+ def mapView(map_view, viewForAnnotation:annotation)
222
+ annotation_view(map_view, annotation)
223
+ end
224
+
225
+ def mapView(map_view, didUpdateUserLocation:userLocation)
222
226
  if self.respond_to?(:on_user_location)
223
227
  on_user_location(userLocation)
224
228
  else
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.1.0
4
+ version: 0.2.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-05-23 00:00:00.000000000 Z
12
+ date: 2014-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ProMotion