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.

  • 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.