v0.6.0
This is a complete rewrite of MapboxDirections.swift that focuses on making the API more Swift-like in Swift but also adds Objective-C support (#47). The goal is no longer to be a drop-in replacement for MapKit’s MKDirections API, but the library continues to use terminology familiar to Cocoa and Cocoa Touch developers. This version includes a number of breaking changes:
- Most types and methods can now be used in Objective-C.
- Removed the
MB
class prefix from Swift but kept it for Objective-C. If any type conflicts with a type in your application’s module, prefix it withMapboxDirections.
. - Added a shared (singleton)
Directions
object. Use the shared object if you’ve set your Mapbox access token in theMGLMapboxAccessToken
key 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 aDirections
object 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
NBNRequestKit
dependency override. Directions
no 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 theURLForCalculatingDirections(options:)
property.- A single directions object uses the shared URL session for all requests, so it can handle multiple requests concurrently without raising an exception.
- Removed the
cancel()
method; instead, directly cancel the NSURLSessionDataTask returned bycalculateDirections(options:completionHandler:)
.
- Removed the dependency on RequestKit. If you’re upgrading to this version using CocoaPods, you can remove the
- Replaced
calculateDirectionsWithCompletionHandler(_:completionHandler:)
andcalculateETAWithCompletionHandler(_:completionHandler:)
with a singlecalculateDirections(options:completionHandler:)
method, which takes aRouteOptions
object that supports all the options exposed by the Geocoding API. If you need to use Mapbox Directions API v4, use aRouteOptionsV4
instead ofRouteOptions
. - Steps are no longer returned by default, and the overview geometry is simplified by default. If you want full, turn-by-turn directions, configure the
RouteOptions
object to include the route steps and full-resolution route shapes. If you only want the estimated travel time or distance to a destination, use the default values inRouteOptions
. - Replaced the
MBDirectionsRequest.TransportType
type with a freeformprofileIdentifier
option. Use one of the three profile identifier constants with this option. - Removed the
MBDirectionsResponse
class in favor of passing the waypoints and routes from the response directly into the completion handler. - Renamed
Route.geometry
toRoute.coordinates
. For Objective-C compatibility, there are additional methods that work with C arrays of coordinates. - Each enumeration’s raw values are integer types instead of strings, but the enumerations also conform to
CustomStringConvertible
in Swift, allowing the enumeration values to be converted to and from strings easily.
Other changes since v0.5.0:
- Added official support for OS X, tvOS, and watchOS. (#49)
- Added documentation for the entire library. You can access the documentation for any symbol using Quick Help (option-click) or Jump to Definition (command-click). (#47)
- Replaced the
TakeRamp
maneuver type withTakeOnRamp
,TakeOffRamp
, andTurnAtRoundabout
to reflect changes in OSRM v5.1.0 and Mapbox Directions API v5. (#45) - Added options to configure what’s included in the output, how close the route needs to come to the specified waypoints, and whether to include routes that U-turn at intermediate waypoints. (#47)
- Added a way to specify the heading accuracy of any waypoint. (#47)
- By default, returned routes may U-turn at intermediate waypoints. (#47)
- Various error conditions returned by the API, such as the rate limiting error, cause the localized failure reason and recovery suggestion to be set in the NSError object that is passed into the completion handler. (#47)
- Requests sent through this library now use a more specific user agent string, so you can more easily identify this library on your Statistics page in Mapbox Studio. (#50)