Mapbox Directions for Swift
Mapbox Directions for Swift (formerly MapboxDirections.swift) makes it easy to connect your iOS, macOS, tvOS, watchOS, or Linux application to the Mapbox Directions and Map Matching APIs. Quickly get driving, cycling, or walking directions, whether the trip is nonstop or it has multiple stopping points, all using a simple interface reminiscent of MapKit’s MKDirections
API. Fit a GPX trace to the OpenStreetMap road network. The Mapbox Directions and Map Matching APIs are powered by the OSRM and Valhalla routing engines. For more information, see the Mapbox Navigation homepage.
Mapbox Directions pairs well with MapboxGeocoder.swift, MapboxStatic.swift, the Mapbox Navigation SDK for iOS, and the Mapbox Maps SDK for iOS or macOS SDK.
Getting started
Specify the following dependency in your Carthage Cartfile:
# Latest stable release
github "mapbox/mapbox-directions-swift" ~> 1.1
# Latest prerelease
github "mapbox/mapbox-directions-swift" "v1.2.0-rc.1"
Or in your CocoaPods Podfile:
# Latest stable release
pod 'MapboxDirections', '~> 1.1'
# Latest prerelease
pod 'MapboxDirections', :git => 'https://github.com/mapbox/mapbox-directions-swift.git', :tag => 'v1.2.0-rc.1'
Or in your Swift Package Manager Package.swift:
// Latest stable release
.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.1.0")
// Latest prerelease
.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "1.2.0-rc.1")
Then import MapboxDirections
.
This repository contains an example application that demonstrates how to use the framework. To run it, you need to use Carthage 0.19 or above to install the dependencies. Detailed documentation is available in the Mapbox API Documentation.
System requirements
- One of the following package managers:
- CocoaPods (CocoaPods 1.10 or above if using Xcode 12)
- Carthage 0.19 or above (run this script instead of
carthage
if using Xcode 12) - Swift Package Manager 5.3 or above
- Xcode 11 or above (Xcode 12 or above if using Swift Package Manager)
- One of the following operating systems:
- iOS 10.0 or above
- macOS 10.12.0 or above
- tvOS 10.0 or above
- watchOS 3.0 or above
- Any Linux distribution supported by Swift
v0.30.0 is the last release of MapboxDirections.swift that supports a minimum deployment target of iOS 9.x, macOS 10.11.x, tvOS 9.x, or watchOS 2.x. v0.30.0 is also the last release that is compatible with Objective-C or AppleScript code.
Usage
You’ll need a Mapbox access token in order to use the API. If you’re already using the Mapbox Maps SDK for iOS or macOS SDK, Mapbox Directions automatically recognizes your access token, as long as you’ve placed it in the MGLMapboxAccessToken
key of your application’s Info.plist file.
The examples below are each provided in Swift (denoted with main.swift
), For further details, see the Mapbox Directions for Swift API reference.
Calculating directions between locations
The main directions class is Directions
. Create a directions object using your access token:
// main.swift
import MapboxDirections
let directions = Directions(credentials: DirectionsCredentials(accessToken: "<#your access token#>"))
Alternatively, you can place your access token in the MGLMapboxAccessToken
key of your application’s Info.plist file, then use the shared directions object:
// main.swift
let directions = Directions.shared
With the directions object in hand, construct a RouteOptions object and pass it into the Directions.calculate(_:completionHandler:)
method.
// main.swift
let waypoints = [
Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.9131752, longitude: -77.0324047), name: "Mapbox"),
Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), name: "White House"),
]
let options = RouteOptions(waypoints: waypoints, profileIdentifier: .automobileAvoidingTraffic)
options.includesSteps = true
let task = directions.calculate(options) { (session, result) in
switch result {
case .failure(let error):
print("Error calculating directions: \(error)")
case .success(let response):
guard let route = response.routes?.first, let leg = route.legs.first else {
return
}
print("Route via \(leg):")
let distanceFormatter = LengthFormatter()
let formattedDistance = distanceFormatter.string(fromMeters: route.distance)
let travelTimeFormatter = DateComponentsFormatter()
travelTimeFormatter.unitsStyle = .short
let formattedTravelTime = travelTimeFormatter.string(from: route.expectedTravelTime)
print("Distance: \(formattedDistance); ETA: \(formattedTravelTime!)")
for step in leg.steps {
print("\(step.instructions)")
let formattedDistance = distanceFormatter.string(fromMeters: step.distance)
print("— \(formattedDistance) —")
}
}
}
This library uses version 5 of the Mapbox Directions API by default.
Matching a trace to the road network
If you have a GPX trace or other GPS-derived location data, you can clean up the data and fit it to the road network using the Map Matching API:
// main.swift
let coordinates = [
CLLocationCoordinate2D(latitude: 32.712041, longitude: -117.172836),
CLLocationCoordinate2D(latitude: 32.712256, longitude: -117.17291),
CLLocationCoordinate2D(latitude: 32.712444, longitude: -117.17292),
CLLocationCoordinate2D(latitude: 32.71257, longitude: -117.172922),
CLLocationCoordinate2D(latitude: 32.7126, longitude: -117.172985),
CLLocationCoordinate2D(latitude: 32.712597, longitude: -117.173143),
CLLocationCoordinate2D(latitude: 32.712546, longitude: -117.173345)
]
let options = MatchOptions(coordinates: coordinates)
options.includesSteps = true
let task = directions.calculate(options) { (session, result) in
switch result {
case .failure(let error):
print("Error matching coordinates: \(error)")
case .success(let response):
guard let match = response.matches?.first, let leg = match.legs.first else {
return
}
print("Match via \(leg):")
let distanceFormatter = LengthFormatter()
let formattedDistance = distanceFormatter.string(fromMeters: match.distance)
let travelTimeFormatter = DateComponentsFormatter()
travelTimeFormatter.unitsStyle = .short
let formattedTravelTime = travelTimeFormatter.string(from: match.expectedTravelTime)
print("Distance: \(formattedDistance); ETA: \(formattedTravelTime!)")
for step in leg.steps {
print("\(step.instructions)")
let formattedDistance = distanceFormatter.string(fromMeters: step.distance)
print("— \(formattedDistance) —")
}
}
}
You can also use the Directions.calculateRoutes(matching:completionHandler:)
method to get Route objects suitable for use anywhere a standard Directions API response would be used.
Usage with other Mapbox libraries
Drawing the route on a map
With the Mapbox Maps SDK for iOS or macOS SDK, you can easily draw the route on a map:
// main.swift
if var routeCoordinates = route.shape?.coordinates, routeCoordinates.count > 0 {
// Convert the route’s coordinates into a polyline.
let routeLine = MGLPolyline(coordinates: &routeCoordinates, count: UInt(routeCoordinates.count))
// Add the polyline to the map.
mapView.addAnnotation(routeLine)
// Fit the viewport to the polyline.
let camera = mapView.cameraThatFitsShape(routeLine, direction: 0, edgePadding: .zero)
mapView.setCamera(camera, animated: true)
}
Displaying a turn-by-turn navigation interface
The Mapbox Navigation SDK for iOS provides a full-fledged user interface for turn-by-turn navigation along routes supplied by MapboxDirections.
Directions CLI
MapboxDirectionsCLI
is a command line tool, designed to round-trip an arbitrary, JSON-formatted Directions or Map Matching API response through model objects and back to JSON. This is useful for various scenarios including testing purposes and designing more sophisticated API response processing pipelines. It is also supplied as a Swift package.
To build MapboxDirectionsCLI
using Carthage pipeline:
carthage build --platform macos
open MapboxDirections.xcodeproj
- Select
MapboxDirectionsCLI
target.
To build MapboxDirectionsCLI
using SPM:
swift build
swift run MapboxDirectionsCLI -h
to see usage.
Github
link |
Stars: 114 |
You may find interesting
Dependencies
Releases
v1.2.0-rc.1 - 2021-01-15T00:12:29
Changes since v1.2.0-alpha.3:
- Fixed an issue where
JSONEncoder
did not encode theIntersection.tollCollection
property. (#510)
Documentation is available online or within Xcode.
v1.2.0-alpha.3 - 2020-12-12T01:52:08
Changes since v1.2.0-alpha.2:
- Added the
Intersection.outletMapboxStreetsRoadClass
property that indicates a more detailed road classification than the existingIntersection.outletRoadClasses
property. (#507) - Added the
RouteLeg.incidents
property that indicates known traffic incidents, toll collection points, rest areas, and border crossings along the route leg. (#466, #506) - Added the
RouteLeg.administrativeRegions
property that indicates the administrative regions traversed by the route leg. (#466, #506) - Added the
Intersection.tunnelName
,Intersection.tollCollection
,Intersection.restStop
, andIntersection.isUrban
properties. (#466, #506)
Documentation is available online or within Xcode.
v1.2.0-alpha.2 - 2020-11-25T13:00:33
Changes since v1.2.0-alpha.1:
- The
CongestionLevel
enumeration now conforms to theCaseIterable
protocol. (#500) - Refined encoding/decoding logic for
AdministrativeRegions
byLeg
andIntersection
(#485). Added few properties for convenience access:Intersection.regionCode
- A 2-letter region code to identify corresponding country that this intersection lies in.RouteLeg.regionCode(atStepIndex:, intersectionIndex:)
- Returns the ISO 3166-1 alpha-2 region code for the administrative region through which the given intersection passes.
- Added
RouteStep.segmentIndicesByIntersection
for navigatingIntersection
s segments along the step; (#490)
v1.2.0-alpha.1 - 2020-11-19T19:57:40
v1.1.0 - 2020-11-12T18:02:35
- Added the
DirectionsResult.typicalTravelTime
,RouteLeg.typicalTravelTime
andRouteStep.typicalTravelTime
properties that indicate the typical travel time, as opposed to the current expected travel time. (#462) - Fixed an error that occurred when setting the
Waypoint.separatesLegs
property totrue
and setting theWaypoint.targetCoordinate
property. (#480) Directions.fetchAvailableOfflineVersions(completionHandler:)
now calls its completion handler on the main queue consistently. (#475)- Upgraded to Polyline v5.0.0. (#487)
Documentation is available online or within Xcode.
v1.1.0-rc.1 - 2020-11-10T00:02:40
- Added the
DirectionsResult.typicalTravelTime
,RouteLeg.typicalTravelTime
andRouteStep.typicalTravelTime
properties that indicate the typical travel time, as opposed to the current expected travel time. (#462) - Fixed an error that occurred when setting the
Waypoint.separatesLegs property
totrue
and setting theWaypoint.targetCoordinate
property. (#480) Directions.fetchAvailableOfflineVersions(completionHandler:)
now calls its completion handler on the main queue consistently. (#475)- Upgraded to Polyline v5.0.0. (#487)
v1.0.0 - 2020-09-24T22:39:07
- Added the
Directions.refreshRoute(responseIdentifier:routeIndex:fromLegAtIndex:completionHandler:)
method for refreshing attributes along the legs of a route and theRoute.refreshLegAttributes(from:)
method for merging the refreshed attributes into an existing route. To enable route refreshing for the routes in a particular route response, setRouteOptions.refreshingEnabled
totrue
before passing theRouteOptions
object intoDirections.calculate(_:completionHandler:)
. (#420) - Fixed a crash that could occur if the Mapbox Directions API includes unrecognized
RoadClasses
values in its response. (#450) - Fixed malformed
RouteStep.shape
values that could occur whenRouteStep.maneuverType
isManeuverType.arrive
,DirectionsOptions.shapeFormat
isRouteShapeFormat.polyline6
, and the Mapbox Directions API returns certain encoded Polyline strings. (#456) - Restored the
DirectionsOptions.urlQueryItems
property so that subclasses ofRouteOptions
andMatchOptions
can add any additional URL query parameters that are supported by the Mapbox Directions and Map Matching APIs. (#461)
Documentation is available online or within Xcode.
v1.0.0-rc.2 - 2020-09-22T00:36:59
Changes since v1.0.0-rc.1:
- Fixed malformed
RouteStep.shape
values that could occur whenRouteStep.maneuverType
isManeuverType.arrive
,DirectionsOptions.shapeFormat
isRouteShapeFormat.polyline6
, and the Mapbox Directions API returns certain encoded Polyline strings. (#456)
Documentation is available online or within Xcode.
v1.0.0-rc.1 - 2020-09-03T23:18:41
- Added the
Directions.refreshRoute(responseIdentifier:routeIndex:fromLegAtIndex:completionHandler:)
method for refreshing attributes along the legs of a route and theRoute.refreshLegAttributes(from:)
method for merging the refreshed attributes into an existing route. To enable route refreshing for the routes in a particular route response, setRouteOptions.refreshingEnabled
totrue
before passing theRouteOptions
object intoDirections.calculate(_:completionHandler:)
. (#420) - Fixed a crash that could occur if the Mapbox Directions API includes unrecognized
RoadClasses
values in its response. (#450)
Documentation is available online or within Xcode.
v0.33.2 - 2020-09-01T14:45:59
- Fixed an issue where waypoints in a
RouteResponse
did not persist theWaypoint.targetCoordinate
,Waypoint.heading
,Waypoint.headingAccuracy
, andWaypoint.allowsArrivingOnOppositeSide
properties from the initialRouteOptions
object. (#446)
Documentation is available online or within Xcode.
v0.33.1 - 2020-08-05T21:21:18
- Fixed an issue where
RouteResponse(matching:options:credentials:)
andDirections.calculateRoutes(matching:completionHandler:)
resulted in misshappenRoute.shape
s andRouteStep.shape
s in the Atlantic Ocean ifMatchOptions.shapeFormat
was set toRouteShapeFormat.polyline6
. (#437)
Documentation is available online or within Xcode.
- 2020-07-31T22:04:15
- Fixed an issue where
RouteResponse(matching:options:credentials:)
andDirections.calculateRoutes(matching:completionHandler:)
resulted in misshappenRoute.shape
s andRouteStep.shape
s in the Atlantic Ocean ifMatchOptions.shapeFormat
was set toRouteShapeFormat.polyline6
. (#437)
Documentation is available online or within Xcode.
v0.33.0 - 2020-06-17T23:30:18
- Fixed an issue where decoding and reencoding a JSON-formatted response from the Mapbox Directions API would cause the
voiceLocale
property to be omitted from route objects. (#424) - Added the
Route(legs:shape:distance:expectedTravelTime:)
andRoute(from:)
initializers. (#430) - Fixed an issue where
VisualInstruction.Component.guidanceView
lacked an image URL. (#432)
Documentation is available online or within Xcode.
v0.32.0 - 2020-06-12T23:38:11
- Removed the
CoordinateBounds
struct in favor ofBoundingBox
from Turf. (#427) - Added the
VisualInstructionBanner.quaternaryInstruction
property andVisualInstruction.Component.guidanceView(image:alternativeText:)
enumeration case to represent a detailed image of an upcoming junction. (#425)
Documentation is available online or within Xcode.
v0.31.0 - 2020-05-29T23:23:12
Packaging
- Renamed MapboxDirections.swift to Mapbox Directions for Swift. The CocoaPods pod is now named MapboxDirections, matching the module name. (#400)
- This library now requires a minimum deployment target of iOS 10.0 or above, macOS 10.12.0 or above, tvOS 10.0 or above, or watchOS 3.0 or above. Older operating system versions are no longer supported. (#379)
- Swift is now required to directly use public types and methods defined by this library. If your application is written in Objective-C or Cocoa-AppleScript, you need to implement your own wrapper in Swift that bridges to Objective-C. (#382)
- This library now depends on Turf. (#382)
Error handling
- The
RouteCompletionHandler
andMatchCompletionHandler
closures’error
argument is now aDirectionsError
instead of anNSError
. (#382) - Classes such as
Route
,Match
, andRouteStep
conform to theCodable
protocol, so you can create instances of them from JSON-formattedData
usingJSONDecoder
and round-trip them back to JSON usingJSONEncoder
. Malformed input now throws decoding errors instead of crashing by unwrappingnil
s. (#382)
Visual instructions
- Removed the
Lane
class in favor of storing an array ofLaneIndication
s directly in theIntersection.approachLanes
property. (#382) - Removed the
ComponentRepresentable
protocol,VisualInstructionComponent
class, andLaneIndicationComponent
class in favor of aVisualInstruction.Component
enumeration that contains aVisualInstruction.Component.TextRepresentation
and/orVisualInstruction.Component.ImageRepresentation
, depending on the type of component. (#382) - Added the
VisualInstruction.Component.ImageRepresentation.imageURL(scale:format:)
method for fetching images with scales other than the current screen’s native scale or formats other than PNG. (#382)
Other changes
- Removed support for Mapbox Directions API v4. (#382)
- Replaced the
MBDefaultWalkingSpeed
,MBMinimumWalkingSpeed
, andMBMaximumWalkingSpeed
constants withCLLocationSpeed.normalWalking
,CLLocationSpeed.minimumWalking
, andCLLocationSpeed.maximumWalking
, respectively. - Replaced the
Route.coordinates
property withRoute.shape
and theRouteStep.coordinates
property withRouteStep.shape
. TheRoute.coordinateCount
andRouteStep.coordinateCount
properties have been removed, but you can use theLineString.coordinates
property to get the array ofCLLocationCoordinate2D
s. (#382) RouteLeg.source
andRouteLeg.destination
are now optional. They can benil
when theRouteLeg
object is decoded individually from JSON. (#382)- Removed
TransportType.none
,ManeuverType.none
, andManeuverDirection.none
. UnrecognizedTransportType
andManeuverDirection
values now raise decoding errors. (#382) RouteStep.maneuverType
is now optional. (#382)- Renamed the
Tracepoint.alternateCount
property toTracepoint.countOfAlternatives
. (#382) - The
Intersection.approachIndex
andIntersection.outletIndex
properties are now optional, not −1, in the case of a departure or arrival maneuver. (#393) - Added initializers for
Route
,Match
,RouteLeg
, andRouteStep
. (#393) - Various properties of
Route
,RouteLeg
, andRouteStep
are now writable. (#393) - Added
AttributeOptions.maximumSpeedLimit
for getting maximum posted speed limits in theRouteLeg.segmentMaximumSpeedLimits
property. (#367) - Added the
RouteLeg.segmentRangesByStep
property for more easily associatingRouteStep
s with the values in segment-based arrays such asRouteLeg.segmentCongestionLevels
. (#367) - The
RouteOptions.alleyPriority
property now works withDirectionsProfileIdentifier.automobile
, allowing you to request routes that prefer or avoid alleys while driving. (#416)
Documentation is available online or within Xcode.
v1.0.0-alpha.1 - 2020-01-11T21:53:26
Packaging
- Renamed MapboxDirections.swift to Mapbox Directions for Swift. The CocoaPods pod is now named MapboxDirections, matching the module name. (#400)
- This library now requires a minimum deployment target of iOS 10.0 or above, macOS 10.12.0 or above, tvOS 10.0 or above, or watchOS 3.0 or above. Older operating system versions are no longer supported. (#379)
- Swift is now required to directly use public types and methods defined by this library. If your application is written in Objective-C or Cocoa-AppleScript, you need to implement your own wrapper in Swift that bridges to Objective-C. (#382)
- This library now depends on Turf. (#382)
Error handling
- The
RouteCompletionHandler
andMatchCompletionHandler
closures’error
argument is now aDirectionsError
instead of anNSError
. (#382) - Classes such as
Route
,Match
, andRouteStep
conform to theCodable
protocol, so you can create instances of them from JSON-formattedData
usingJSONDecoder
and round-trip them back to JSON usingJSONEncoder
. Malformed input now throws decoding errors instead of crashing by unwrappingnil
s. (#382)
Visual instructions
- Removed the
Lane
class in favor of storing an array ofLaneIndication
s directly in theIntersection.approachLanes
property. (#382) - Removed the
ComponentRepresentable
protocol,VisualInstructionComponent
class, andLaneIndicationComponent
class in favor of aVisualInstruction.Component
enumeration that contains aVisualInstruction.Component.TextRepresentation
and/orVisualInstruction.Component.ImageRepresentation
, depending on the type of component. (#382) - Added the
VisualInstruction.Component.ImageRepresentation.imageURL(scale:format:)
method for fetching images with scales other than the current screen’s native scale or formats other than PNG. (#382)
Other changes
- Removed support for Mapbox Directions API v4. (#382)
- Replaced the
MBDefaultWalkingSpeed
,MBMinimumWalkingSpeed
, andMBMaximumWalkingSpeed
constants withCLLocationSpeed.normalWalking
,CLLocationSpeed.minimumWalking
, andCLLocationSpeed.maximumWalking
, respectively. - Replaced the
Route.coordinates
property withRoute.shape
and theRouteStep.coordinates
property withRouteStep.shape
. TheRoute.coordinateCount
andRouteStep.coordinateCount
properties have been removed, but you can use theLineString.coordinates
property to get the array ofCLLocationCoordinate2D
s. (#382) RouteLeg.source
andRouteLeg.destination
are now optional. They can benil
when theRouteLeg
object is decoded individually from JSON. (#382)- Removed
TransportType.none
,ManeuverType.none
, andManeuverDirection.none
. UnrecognizedTransportType
andManeuverDirection
values now raise decoding errors. (#382) RouteStep.maneuverType
is now optional. (#382)- Renamed the
Tracepoint.alternateCount
property toTracepoint.countOfAlternatives
. (#382) - The
Intersection.approachIndex
andIntersection.outletIndex
properties are now optional, not −1, in the case of a departure or arrival maneuver. (#393) - Added initializers for
Route
,Match
,RouteLeg
, andRouteStep
. (#393) - Various properties of
Route
,RouteLeg
, andRouteStep
are now writable. (#393) - Added
AttributeOptions.maximumSpeedLimit
for getting maximum posted speed limits in theRouteLeg.segmentMaximumSpeedLimits
property. (#367) - Added the
RouteLeg.segmentRangesByStep
property for more easily associatingRouteStep
s with the values in segment-based arrays such asRouteLeg.segmentCongestionLevels
. (#367)
Documentation is available online or within Xcode.
v0.30.0 - 2019-07-27T02:43:04
Directions.fetchAvailableOfflineVersions(completionHandler:)
andDirections.downloadTiles(in:version:completionHandler:)
now resumes the data task before returning it to conform to its naming conventions and avoid confusion. (#353)
Documentation is available online or within Xcode.
v0.29.0 - 2019-06-27T00:54:18
v0.28.0 - 2019-05-16T16:07:37
- Added the
RouteOptions.alleyPriority
,RouteOptions.walkwayPriority
, andRouteOptions.speed
properties for fine-tuning walking directions. (#370) - Added the
MBStringFromManeuverType()
,MBStringFromManeuverDirection()
,MBStringFromDrivingSide()
, andMBStringFromTransportType()
functions, which are intended for use in Objective-C. (#369)
Documentation is available online or within Xcode.
v0.27.3 - 2019-04-04T21:04:25
- Fixed compatibility issues with Xcode 10.2 when the SDK is installed using Carthage. (#363)
Documentation is available online or within Xcode.
v0.27.2 - 2019-02-27T00:55:42
- Fixed an issue where
Waypoint.separatesLegs
caused the resultingRouteLeg.source
andRouteLeg.destination
to have mismatched coordinates and names. (#358) - Fixed an issue where a Directions API or Map Matching API request would fail if a
Waypoint
hasWaypoint.name
set andWaypoint.separatesLegs
set tofalse
. (#358)
Documentation is available online or within Xcode.
v0.27.1 - 2019-02-23T00:55:33
Offline routing
- Fixed an issue where
Directions.downloadTiles(in:version:session:completionHandler:)
always failed with an error after passing in aCoordinateBounds
created using theCoordinateBounds(northWest:southEast:)
initializer. (#349) - Added a
CoordinateBounds(southWest:northEast:)
initializer. (#349) - The versions passed into the completion handler of
Directions.fetchAvailableOfflineVersions(completionHandler:)
are now sorted in reverse chronological order. (#350)
Other changes
- Fixed issues where
VisualInstruction
,VisualInstructionBanner
,VisualInstructionComponent
,LaneIndicationComponent
, andRouteOptionsV4
objects failed to roundtrip throughNSCoder
. (#351)
Documentation is available online or within Xcode.
v0.27.0 - 2019-02-09T00:44:30
- If a
RouteOptions
object has exceptionally many waypoints or if many of the waypoint have very long names,Directions.calculate(_:completionHandler:)
sends a POST request to the Mapbox Directions API instead of sending a GET request that returns an error. (#341) - When possible,
Directions.calculateRoutes(matching:completionHandler:)
now sends a GET request to the Mapbox Map Matching API instead of a POST request. (#341) - Fixed an issue where certain waypoint names would cause
Directions.calculateRoutes(matching:completionHandler:)
to return an error. (#341) - Added the
Directions.url(forCalculating:httpMethod:)
andDirections.urlRequest(forCalculating:)
methods for implementing custom GET- and POST-compatible request code. (#341) - Added the
Waypoint.separatesLegs
property, which you can set tofalse
to create a route that travels “via” the waypoint but doesn’t stop there. Deprecated theMatchOptions.waypointIndices
property in favor ofWaypoint.separatesLegs
, which also works withRouteOptions
. (#340) - Fixed unset properties in
Waypoint
objects that are included in a calculatedRoute
s orMatch
es. (#340) - Added
DirectionsResult.fetchStartDate
andDirectionsResult.requestEndDate
properties. (#335) - Added a
DirectionsOptions.urlQueryItems
property so that subclasses ofRouteOptions
andMatchOptions
can add any additional URL query parameters that are supported by the Mapbox Directions and Map Matching APIs. (#343)
Documentation is available online or within Xcode.
v0.26.1 - 2019-01-24T00:27:58
Waypoint
s andTracepoint
s can now be compared for object equality. (#331)- Fixed an issue where the
DirectionsResult.accessToken
andDirectionsResult.apiEndpoint
properties failed to roundtrip throughNSCoder
. (#331) Route
now supports secure coding via theNSSecureCoding
protocol. (#331)- Fixed an issue where
Intersection
failed to decode when an outlet road has no road classes (i.e., a normal road that isn’t a bridge, tunnel, toll road, or motorway). (#331)
Documentation is available online or within Xcode.
v0.26.0 - 2018-12-20T10:01:09
- Renamed
CoordinateBounds(_:)
toCoordinateBounds(coordinates:)
. (#325) - Added a
Waypoint.targetCoordinate
property for specifying a more specific destination for arrival instructions. (#326) - Fixed an issue where the
Waypoint.allowsArrivingOnOppositeSide
property was not copied when copying aWaypoint
object. (#326)
Documentation is available online or within Xcode.
v0.25.2 - 2018-12-06T07:07:15
- Fixed an issue where
VisualInstructionComponent(json:)
would setVisualInstructionComponent.imageURL
to an invalid URL when the JSON representation includes an empty image URL. (#322)
Documentation is available online or within Xcode.
v0.25.1 - 2018-11-21T23:36:39
- Added the
Directions.apiEndpoint
andDirections.accessToken
properties that reflect the values passed into theDirections
class’s initializers. (#313) - Fixed an issue causing some requests with many waypoints or long waypoint names to fail. (#311)
- Fixed an issue where some requests with very many waypoints would fail silently. (#314)
Documentation is available online or within Xcode.
v0.25.0 - 2018-11-01T17:26:55
v0.24.1 - 2018-10-23T19:39:05
- Added
RouteOptions.response(from:)
which can be used for deserializing a response from an external source.
Documentation is available online or within Xcode.
v0.24.0 - 2018-10-01T02:10:12
DirectionsResult
now includes the API response as JSON
Documentation is available online or within Xcode.