diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7b8aeb..13e6a29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Change Log
+## [1.2.0](https://github.com/JeromeTan1997/LocationPicker/releases/tag/1.2.0) (2016-06-10)
+
+#### Enhancements
+
+- Add the capability to allow the selection of locations that did not match or exactly match search results [#6](https://github.com/JeromeTan1997/LocationPicker/pull/6)
+
## [1.1.2](https://github.com/JeromeTan1997/LocationPicker/releases/tag/1.1.2) (2016-06-10)
#### API breaking changes
diff --git a/LocationPicker/Info.plist b/LocationPicker/Info.plist
index 3034b22..331a2da 100644
--- a/LocationPicker/Info.plist
+++ b/LocationPicker/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.1.2
+ 1.2.0
CFBundleSignature
????
CFBundleVersion
diff --git a/LocationPicker/LocationItem.swift b/LocationPicker/LocationItem.swift
index 65154d3..080ce26 100644
--- a/LocationPicker/LocationItem.swift
+++ b/LocationPicker/LocationItem.swift
@@ -66,7 +66,7 @@ public class LocationItem: NSObject, NSCoding {
}
}
- /// The coordinate of the location. A reference to `MKMapItem` object's property `placemark.coordinate` and converted to tuple.
+ /// The coordinate of the location. A reference to `MKMapItem` object's property `placemark.coordinate` and converted to tuple. Only when the `allowArbitraryLocation` property of `LocationPicker` class is set to `true`, can this property be `nil`.
public var coordinate: (latitude: Double, longitude: Double)? {
get {
let coordinate = mapItem.placemark.coordinate
diff --git a/LocationPicker/LocationPicker.swift b/LocationPicker/LocationPicker.swift
index de0873e..ebe85fb 100644
--- a/LocationPicker/LocationPicker.swift
+++ b/LocationPicker/LocationPicker.swift
@@ -201,7 +201,7 @@ public class LocationPicker: UIViewController, UISearchBarDelegate, UITableViewD
/**
- Allows the selection of locations that did not exactly match search results.
+ Allows the selection of locations that did not match or exactly match search results.
- Note:
If an arbitrary location is selected, its coordinate in `LocationItem` will be `nil`. __Default__ is __`false`__.
@@ -768,10 +768,14 @@ public class LocationPicker: UIViewController, UISearchBarDelegate, UITableViewD
MKLocalSearch(request: localSearchRequest).startWithCompletionHandler({ (localSearchResponse, error) -> Void in
guard error == nil,
let localSearchResponse = localSearchResponse where localSearchResponse.mapItems.count > 0 else {
- let locationItem = LocationItem(locationName: searchText)
- self.searchResultLocations = [locationItem]
- self.tableView.reloadData()
- return
+ if self.allowArbitraryLocation {
+ let locationItem = LocationItem(locationName: searchText)
+ self.searchResultLocations = [locationItem]
+ } else {
+ self.searchResultLocations = []
+ }
+ self.tableView.reloadData()
+ return
}
self.searchResultLocations = localSearchResponse.mapItems.map({ LocationItem(mapItem: $0) })
diff --git a/LocationPickerViewController.podspec b/LocationPickerViewController.podspec
index 652531b..b7dc608 100644
--- a/LocationPickerViewController.podspec
+++ b/LocationPickerViewController.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LocationPickerViewController"
- s.version = "1.1.2"
+ s.version = "1.2.0"
s.summary = "A ready for use and fully customizable location picker for your app."
s.homepage = "https://github.com/JeromeTan1997/LocationPicker"
diff --git a/README.md b/README.md
index fea5100..b7fd696 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ let package = Package(
name: "Your Project Name",
targets: [],
dependencies: [
- .Package(url: "https://github.com/JeromeTan1997/LocationPicker.git", versions: "1.1.2" ..< Version.max)
+ .Package(url: "https://github.com/JeromeTan1997/LocationPicker.git", versions: "1.2.0" ..< Version.max)
]
)
```
@@ -193,6 +193,7 @@ __Grant__ button will direct user to the Settings where location access can be c
| Property name | Default | Target | Remark |
| ------------- |:-------:| ------ | ------ |
+| allowArbitraryLocation | false | | Allows the selection of locations that did not match or exactly match search results |
| mapViewZoomEnabled | true | mapView.zoomEnabled | Whether the map view can zoom in and out |
| mapViewShowsUserLocation | true | mapView.showsUserLocation | Whether the map view shows user's location |
| mapViewScrollEnabled | true | mapView.scrollEnabled | Whether user can scroll the map view |
@@ -428,7 +429,7 @@ The hash value of `LocationItem` is `"\(coordinate.latitude), \(coordinate.longi
| Property name | Type | Target | Remark |
| ------------- |:----:| ------ | ------ |
| name | String | mapItem.name | The name of the location |
-| coordinate | (latitude: Double, longitude: Double)? | mapItem.placemark.coordinate | The coordinate of the location and converted to tuple. If the user is offline or there is no search result, this property will be `nil` |
+| coordinate | (latitude: Double, longitude: Double)? | mapItem.placemark.coordinate | The coordinate of the location and converted to tuple. If the user is offline or there is no search result and the `allowArbitraryLocation` property of `LocationPicker` is set to `true`, this property will be `nil` |
| addressDictionary | [NSObject: AnyObject]? | mapItem.placemark.addressDictionary | The address dictionary of the location |
| formattedAddressString | String? | addressDictionary?["FormattedAddressLines"] | The address text formatted according to user's region |