Skip to content

v0.6.0

Compare
Choose a tag to compare
@1ec5 1ec5 released this 06 Jun 21:54
· 1128 commits to master since this release

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 with MapboxDirections..
  • Added a shared (singleton) Directions object. Use the shared object if you’ve set your Mapbox access token in the MGLMapboxAccessToken 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 a Directions 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 the URLForCalculatingDirections(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 by calculateDirections(options:completionHandler:).
  • Replaced calculateDirectionsWithCompletionHandler(_:completionHandler:) and calculateETAWithCompletionHandler(_:completionHandler:) with a single calculateDirections(options:completionHandler:) method, which takes a RouteOptions object that supports all the options exposed by the Geocoding API. If you need to use Mapbox Directions API v4, use a RouteOptionsV4 instead of RouteOptions.
  • 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 in RouteOptions.
  • Replaced the MBDirectionsRequest.TransportType type with a freeform profileIdentifier 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 to Route.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 with TakeOnRamp, TakeOffRamp, and TurnAtRoundabout 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)