README.md in ProMotion-map-0.5.0 vs README.md in ProMotion-map-0.6.0
- old
+ new
@@ -19,10 +19,11 @@
```ruby
class MyMapScreen < PM::MapScreen
title "My Map"
start_position latitude: 35.090648651123, longitude: -82.965972900391, radius: 4
+ tap_to_add
def annotation_data
[{
longitude: -82.965972900391,
latitude: 35.090648651123,
@@ -52,12 +53,11 @@
title: "Stairway Falls",
subtitle: "Gorges State Park",
your_param: "CustomWhatever",
action: :show_forest
}, {
- longitude: -82.965972900391,
- latitude: 35.090648651123,
+ coordinate: CLLocationCoordinate2DMake(35.090648651123, -82.965972900391)
title: "Rainbow Falls",
subtitle: "Nantahala National Forest",
image: UIImage.imageNamed("custom-pin"),
action: :show_forest
}]
@@ -89,23 +89,28 @@
All possible properties:
```ruby
{
- longitude: -82.956244328014, # REQUIRED
- latitude: 35.085548421623, # REQUIRED
+ # REQUIRED -or- use :coordinate
+ longitude: -82.956244328014,
+ latitude: 35.085548421623,
+
+ # REQUIRED -or- use :longitude & :latitude
+ coordinate: CLLocationCoordinate2DMake(35.085548421623, -82.956244328014)
+
title: "Stairway Falls", # REQUIRED
subtitle: "Gorges State Park",
image: "my_custom_image",
left_accessory: my_button,
right_accessory: my_other_button,
action: :my_action, # Overrides :right_accessory
action_button_type: UIButtonTypeContactAdd # Defaults to UIButtonTypeDetailDisclosure
}
```
-You may pass whatever properties you want in the annotation hash, but `:longitude`, `:latitude`, and `:title` are required.
+You may pass whatever properties you want in the annotation hash, but (`:longitude` && `:latitude` || `:coordinate`), and `:title` are required.
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.
Use `:left_accessory` and `:right_accessory` to specify a custom accessory, like a button.
@@ -129,12 +134,27 @@
Sets the center of the map. `animated` property defaults to `true`.
#### show_user_location
-Shows the user's location on the map.
+Shows the user's location on the map. Must be called in the view initialization sequence on `will_appear` or _after_.
+#### look_up_location(CLLocation) { |placemark, error| }
+
+This method takes a CLLocation object and will return one to many CLPlacemark to represent nearby data.
+
+##### iOS 8 Location Requirements
+
+iOS 8 introduced stricter location services requirements. You are now required to add a few key/value pairs to the `Info.plist`. Add these two lines to your `Rakefile` (with your descriptions, obviously):
+
+```ruby
+app.info_plist['NSLocationAlwaysUsageDescription'] = 'Description'
+app.info_plist['NSLocationWhenInUseUsageDescription'] = 'Description'
+```
+
+*Note: you need both keys to use `get_once`, so it's probably best to just include both no matter what.* See [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW18) on iOS 8 location services requirements for more information.
+
#### hide_user_location
Hides the user's location on the map.
#### showing_user_location?
@@ -213,9 +233,78 @@
start_position latitude: 36.10, longitude: -80.26, radius: 4
end
```
`radius` is the zoom level of the map in miles (default: 10).
+
+#### tap_to_add(length: Float, target: Object, action: Selector, annotation: Hash)
+
+Lets a user long press the map to drop an annotation where they pressed.
+
+##### Default values:
+
+You can override any of these values. The `annotation` parameter can take any options specified in the annotation documentation above except `:latitude`, `:longitude`, and `:coordinate`.
+
+```ruby
+length: 2.0,
+target: self,
+action: "gesture_drop_pin:",
+annotation: {
+ title: "Dropped Pin",
+ animates_drop: true
+}
+```
+
+##### Notifications
+
+This feature posts two different `NSNotificationCenter` notifications:
+
+**ProMotionMapWillAddPin:** Fired the moment the long press gesture is recognized, before the pin is added.
+
+**ProMotionMapAddedPin:** Fired after the pin has been added to the map.
+
+##### Example:
+
+```ruby
+# Simple Example
+class MyMapScreen < PM::MapScreen
+ title "My Map Screen"
+ tap_to_add length: 1.5
+ def annotations
+ []
+ end
+end
+```
+
+```ruby
+# A More Complex Example
+class MyMapScreen < PM::MapScreen
+ title "My Map Screen"
+ tap_to_add length: 1.5, annotation: {animates_drop: true, title: "A Cool New Pin"}
+ def annotations
+ []
+ end
+
+ def will_appear
+ NSNotificationCenter.defaultCenter.addObserver(self, selector:"pin_adding:") , name:"ProMotionMapWillAddPin", object:nil)
+ NSNotificationCenter.defaultCenter.addObserver(self, selector:"pin_added:") , name:"ProMotionMapAddedPin", object:nil)
+ end
+
+ def will_disappear
+ NSNotificationCenter.defaultCenter.removeObserver(self)
+ end
+
+ def pin_adding(notification)
+ # We only want one pin on the map at a time
+ clear_annotations
+ end
+
+ def pin_added(notification)
+ # Once the pin is dropped we want to select it
+ select_annotation_at(0)
+ end
+end
+```
---
### CocoaTouch Property Convenience Methods