v0.5.0
This is a complete rewrite of MapboxGeocoder.swift that focuses on making the API more Swift-like in Swift but also improves Objective-C support (#41). The goal is no longer to be a drop-in replacement for Core Location’s CLGeocoder API, but the library continues to use terminology familiar to Cocoa and Cocoa Touch developers. This version includes a number of breaking changes:
- Removed the
MBclass prefix from Swift but kept it for Objective-C. - Added a shared (singleton)
Geocoderobject. Use the shared object if you’ve set your Mapbox access token in theMGLMapboxAccessTokenkey of your application’s Info.plist file. (You may have already done so if you’ve installed the Mapbox iOS SDK or Mapbox OS X SDK.) Otherwise, create aGeocoderobject with the access token explicitly. - Simplified the networking part of the library:
- Removed the dependency on RequestKit. If you’re upgrading to this version using CocoaPods, you can remove the
NBNRequestKitdependency override. Geocoderno longer needs to be strongly held in order for the request to finish. Instead, the request is made against the shared URL session; to use a custom URL session, make the request yourself using the URL returned by theURLForGeocoding(options:)property.- A single geocoder object uses the shared URL session for all requests, so it can handle multiple requests concurrently without raising an exception.
- Removed the
cancelGeocode()method; instead, directly cancel the NSURLSessionDataTask returned bygeocode(options:completionHandler:).
- Removed the dependency on RequestKit. If you’re upgrading to this version using CocoaPods, you can remove the
- Replaced
geocodeAddressString(_:completionHandler:)andreverseGeocodeLocation(_:completionHandler:)with a singlegeocode(options:completionHandler:)method that takes aGeocodeOptionsobject. The two concrete subclasses ofGeocodeOptions,ForwardGeocodeOptionsandReverseGeocodeOptions, support all the options exposed by the Geocoding API. - Added an attribution parameter to the completion handler that contains required legal notices.
- Replaced the
Placemark.Scopeenum with aPlacemarkScopebitmask. Renamed.AdministrativeAreato.Region. - Removed the
CLLocationCoordinate2Dequality operator to avoid conflicts with client code that may define the same.
There are also many breaking changes to the Placemark object that results from a request to the API:
- For
Placemarkobjects representing addresses and points of interest, thenameproperty is no longer fully qualified; that is, it no longer contains the full administrative hierarchy. For the fully-qualified name, use thequalifiedNameproperty. - Properties such as
countryandpostalCodereturnPlacemarkobjects instead of strings. To get the name of e.g. the surrounding country, use the returned placemark object’snameproperty. - Renamed
ISOcountryCodetocode. This property may be included in subnational placemarks, such as placemarks representing regions. - Replaced the
administrativeAreaandsubAdministrativeAreaproperties withadministrativeRegionanddistrict, respectively. Unlike the oldsubAdministrativeRegionproperty,districtmay benilif it isn’t applicable. - Renamed
localitytoplace, andsubLocalitytoneighborhood.
Other changes since v0.4.2:
- Added official support for OS X, tvOS, and watchOS. (#44, #48)
- Added support for the Contacts framework’s
CNPostalAddressclass. You can directly forward geocode aCNPostalAddress. You can also get thepostalAddressof a placemark, suitable to format withCNPostalAddressFormatteror place inside aCNContact. (#41, #42) - Added options for disabling autocompletion behavior and limiting results to a rectangular region. (#41)
- Added support for batch geocoding requests via
ForwardBatchGeocodeOptionsandForwardReverseGeocodeOptions. (#41) - When a request fails, the returned error includes a failure reason. When the error is due to rate-limiting, the error also includes a hint that indicates how long to wait before making another request. (#41)
- A new
superiorPlacemarksproperty returns the entire hierarchy of placemarks (in indexer order) that contain a given placemark, in case there’s any overlap between containing placemarks. (#41) - Added a
wikidataItemIdentifierproperty identifying a placemark’s corresponding Wikidata item. (#41)