Isochrones
open class Isochrones
Computes areas that are reachable within a specified amount of time or distance from a location, and returns the reachable regions as contours of polygons or lines that you can display on a map.
-
A tuple type representing the isochrone session that was generated from the request.
Declaration
Swift
public typealias Session = (options: IsochroneOptions, credentials: Credentials)
Parameters
options
A
IsochroneOptions
object representing the request parameter options.credentials
A object containing the credentials used to make the request.
-
A closure (block) to be called when a isochrone request is complete.
Declaration
Swift
public typealias IsochroneCompletionHandler = (_ session: Session, _ result: Result<FeatureCollection, IsochroneError>) -> Void
Parameters
session
A
Isochrones.Session
object containing session informationresult
A
Result
enum that represents theFeatureCollection
if the request returned successfully, or the error if it did not.
-
The Authorization & Authentication credentials that are used for this service.
If nothing is provided, the default behavior is to read credential values from the developer’s Info.plist.
Declaration
Swift
public let credentials: Credentials
-
The shared isochrones object.
To use this object, a Mapbox access token should be specified in the
MBXAccessToken
key in the main application bundle’s Info.plist.Declaration
Swift
public static let shared: Isochrones
-
Creates a new instance of Isochrones object.
Declaration
Swift
public init(credentials: Credentials = .init(), urlSession: URLSession = .shared, processingQueue: DispatchQueue = .global(qos: .userInitiated))
Parameters
credentials
Credentials that will be used to make API requests to Mapbox Isochrone API.
urlSession
URLSession that will be used to submit API requests to Mapbox Isochrone API.
processingQueue
A DispatchQueue that will be used for CPU intensive work.
-
Begins asynchronously calculating isochrone contours using the given options and delivers the results to a closure.
This method retrieves the contours asynchronously from the Mapbox Isochrone API over a network connection. If a connection error or server error occurs, details about the error are passed into the given completion handler in lieu of the contours.
Contours may be displayed atop a Mapbox map.
Declaration
Swift
@discardableResult open func calculate(_ options: IsochroneOptions, completionHandler: @escaping IsochroneCompletionHandler) -> URLSessionDataTask
Parameters
options
A
IsochroneOptions
object specifying the requirements for the resulting contours.completionHandler
The closure (block) to call with the resulting contours. This closure is executed on the application’s main thread.
Return Value
The data task used to perform the HTTP request. If, while waiting for the completion handler to execute, you no longer want the resulting contours, cancel this task.
-
The GET HTTP URL used to fetch the contours from the API.
Declaration
Swift
open func url(forCalculating options: IsochroneOptions) -> URL
Parameters
options
A
IsochroneOptions
object specifying the requirements for the resulting contours.Return Value
The URL to send the request to.
-
The HTTP request used to fetch the contours from the API.
Declaration
Swift
open func urlRequest(forCalculating options: IsochroneOptions) -> URLRequest
Parameters
options
A
IsochroneOptions
object specifying the requirements for the resulting routes.Return Value
A GET HTTP request to calculate the specified options.