MapboxCoreMaps.OfflineManager

extension MapboxCoreMaps.OfflineManager
  • Construct a new offline manager

    Declaration

    Swift

    public convenience init(resourceOptions: ResourceOptions)

    Parameters

    resourceOptions

    ResourceOptions the resource options to manage.

  • Loads a new style package or updates the existing one.

    If a style package with the given id already exists, its updated with the values provided to the given load options. The missing resources get loaded and the expired resources get updated.

    If there no values provided to the given load options, the existing style package gets refreshed: the missing resources get loaded and the expired resources get updated.

    A failed load request can be reattempted with another loadStylePack() call.

    If the style cannot be fetched for any reason, the load request is terminated. If the style is fetched but loading some of the style package resources fails, the load request proceeds trying to load the remaining style package resources.

    Important

    By default, users may download up to 250MB of data for offline use without incurring additional charges. This limit is subject to change.

    Declaration

    Swift

    @discardableResult
    public func loadStylePack(for styleURI: StyleURI,
                              loadOptions: StylePackLoadOptions,
                              progress: StylePackLoadProgressCallback? = nil,
                              completion: @escaping (Result<StylePack, Error>) -> Void) -> Cancelable

    Parameters

    styleURI

    The URI of the style package’s associated style

    loadOptions

    The style package load options.

    progress

    Invoked multiple times to report progress of the loading operation.

    completion

    Invoked only once upon success, failure, or cancelation of the loading operation. Any Result error could be of type StylePackError.

    Return Value

    Returns a Cancelable object to cancel the load request

  • Fetch an array of the existing style packages.

    Note

    The user-provided callbacks will be executed on a worker thread; it is the responsibility of the user to dispatch to a user-controlled thread.

    Declaration

    Swift

    public func allStylePacks(completion: @escaping (Result<[StylePack], Error>) -> Void)

    Parameters

    completion

    The result callback. Any Result error should be of type StylePackError.

  • Returns a style package by its id.

    Note

    The user-provided callbacks will be executed on a worker thread; it is the responsibility of the user to dispatch to a user-controlled thread.

    Declaration

    Swift

    public func stylePack(for styleURI: StyleURI, completion: @escaping (Result<StylePack, Error>) -> Void)

    Parameters

    styleURI

    The URI of the style package’s associated style

    completion

    The result callback. Any Result error could be of type StylePackError.

  • Returns a style package’s associated metadata.

    The style package’s associated metadata that a user previously set.

    Declaration

    Swift

    public func stylePackMetadata(for styleURI: StyleURI,
                                  completion: @escaping (Result<AnyObject, Error>) -> Void)

    Parameters

    styleURI

    The URI of the style package’s associated style

    completion

    The result callback. Any Result error could be of type StylePackError.

  • Removes a style package.

    Removes a style package from the existing packages list. The actual resources eviction might be deferred. All pending loading operations for the style package with the given id will fail with Canceled error.

    Declaration

    Swift

    public func removeStylePack(for styleURI: StyleURI)

    Parameters

    styleURI

    The URI of the style package’s associated style