MapboxMap

public final class MapboxMap
extension MapboxMap: MapEventsObservable

Undocumented

  • The style object supports run time styling.

    Declaration

    Swift

    public internal(set) var style: Style { get }
  • Loads a style from a StyleURI, calling a completion closure when the style is fully loaded or there has been an error during load.

    Declaration

    Swift

    public func loadStyleURI(_ styleURI: StyleURI, completion: ((Result<Style, Error>) -> Void)? = nil)

    Parameters

    styleURI

    StyleURI to load

    completion

    Closure called when the style has been fully loaded. The Result type encapsulates the Style or error that occurred. See MapLoadingError

  • Loads a style from a JSON string, calling a completion closure when the style is fully loaded or there has been an error during load.

    Declaration

    Swift

    public func loadStyleJSON(_ JSON: String, completion: ((Result<Style, Error>) -> Void)? = nil)

    Parameters

    styleURI

    Style JSON string

    completion

    Closure called when the style has been fully loaded. The Result type encapsulates the Style or error that occurred. See MapLoadingError

  • When loading a map, if prefetchZoomDelta is set to any number greater than 0, the map will first request a tile for zoom - prefetchZoomDelta in an attempt to display a full map at lower resolution as quick as possible.

    It will get clamped at the tile source minimum zoom. The default delta is 4.

    Declaration

    Swift

    public var prefetchZoomDelta: UInt8 { get set }
  • Gets the resource options for the map.

    All optional fields of the returned object are initialized with the actual values.

    Note

    The result of this property is different from the ResourceOptions that were provided to the map’s initializer.

    Declaration

    Swift

    public var resourceOptions: ResourceOptions { get }
  • Clears temporary map data.

    Clears temporary map data from the data path defined in the given resource options. Useful to reduce the disk usage or in case the disk cache contains invalid data.

    Note

    Calling this API will affect all maps that use the same data path and does not affect persistent map data like offline style packages.

    Declaration

    Swift

    public static func clearData(for resourceOptions: ResourceOptions, completion: @escaping (Error?) -> Void)

    Parameters

    resourceOptions

    The resource options that contain the map data path to be used

    completion

    Called once the request is complete

  • Gets elevation for the given coordinate.

    Note

    Elevation is only available for the visible region on the screen.

    Declaration

    Swift

    public func elevation(at coordinate: CLLocationCoordinate2D) -> Double?

    Parameters

    coordinate

    Coordinate for which to return the elevation.

    Return Value

    Elevation (in meters) multiplied by current terrain exaggeration, or empty if elevation for the coordinate is not available.

  • Transforms a view’s frame into a set of coordinate bounds

    Declaration

    Swift

    public func coordinateBounds(for rect: CGRect) -> CoordinateBounds

    Parameters

    rect

    The rect whose bounds will be transformed into a set of map coordinate bounds.

    Return Value

    A CoordinateBounds object that represents the southwest and northeast corners of the view’s bounds.

  • Transforms a set of map coordinate bounds to a CGRect relative to the MapView.

    Declaration

    Swift

    public func rect(for coordinateBounds: CoordinateBounds) -> CGRect

    Parameters

    coordinateBounds

    The coordinateBounds that will be converted into a rect relative to the MapView

    Return Value

    A CGRect whose corners represent the vertices of a set of CoordinateBounds.

  • Declaration

    Swift

    public var options: MapOptions { get }
  • Declaration

    Swift

    public func subscribe(_ observer: Observer, events: [String])
  • Declaration

    Swift

    public func unsubscribe(_ observer: Observer, events: [String] = [])
  • Clears temporary map data.

    Clears temporary map data from the data path defined in the given resource options. Useful to reduce the disk usage or in case the disk cache contains invalid data.

    Note

    Calling this API will affect all maps that use the same data path and does not affect persistent map data like offline style packages.

    Declaration

    Swift

    public func clearData(completion: @escaping (Error?) -> Void)

    Parameters

    completion

    Called once the request is complete

  • Update the state map of a feature within a style source. Update entries in the state map of a given feature within a style source. Only entries listed in the state map will be updated. An entry in the feature state map that is not listed in state will retain its previous value.

    Declaration

    Swift

    public func setFeatureState(sourceId: String, sourceLayerId: String? = nil, featureId: String, state: [String : Any])

    Parameters

    sourceId

    Style source identifier

    sourceLayerId

    Style source layer identifier (for multi-layer sources such as vector sources). Defaults to nil.

    featureId

    Identifier of the feature whose state should be updated

    state

    Map of entries to update with their respective new values

  • Get the state map of a feature within a style source.

    Declaration

    Swift

    public func getFeatureState(sourceId: String, sourceLayerId: String? = nil, featureId: String, callback: @escaping (Result<[String : Any], Error>) -> Void)

    Parameters

    sourceId

    Style source identifier.

    sourceLayerId

    Style source layer identifier (for multi-layer sources such as vector sources).

    featureId

    Identifier of the feature whose state should be queried.

    callback

    Feature’s state map or an empty map if the feature could not be found.

  • Removes entries from a feature state object. Remove a specified property or all property from a feature’s state object, depending on the value of stateKey.

    Declaration

    Swift

    public func removeFeatureState(sourceId: String, sourceLayerId: String? = nil, featureId: String, stateKey: String? = nil)

    Parameters

    sourceId

    The style source identifier

    sourceLayerId

    The style source layer identifier (for multi-layer sources such as vector sources). Defaults to nil.

    featureId

    The feature identifier of the feature whose state should be removed.

    stateKey

    The key of the property to remove. If nil, all feature’s state object properties are removed. Defaults to nil.