MTStyle

@MainActor
public class MTStyle

The proxy object for the current map style.

Set of convenience methods for style, sources and layers manipulation. MTStyle is nil until map loading is complete. Since it is loaded asynchronously it should be manipulated only after MTEvent.didLoad triggers.

  • Current reference style of the map object.

    Declaration

    Swift

    @MainActor
    public private(set) var referenceStyle: MTMapReferenceStyle { get }
  • Current style variant of the map object.

    Declaration

    Swift

    @MainActor
    public private(set) var styleVariant: MTMapStyleVariant? { get }
  • Updates the map’s style object with a new value.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setStyle(
        _ referenceStyle: MTMapReferenceStyle,
        styleVariant: MTMapStyleVariant?,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )

    Parameters

    referenceStyle

    Desired reference map style.

    styleVariant

    Optional variant of the reference style.

    completionHandler

    A handler block to execute when function finishes.

  • Returns variants for the current reference style if they exist.

    Declaration

    Swift

    @MainActor
    public func getVariantsForCurrentReferenceStyle() -> [MTMapStyleVariant]?
  • Returns variants for the provided reference style if they exist.

    Declaration

    Swift

    @MainActor
    public func getVariants(for referenceStyle: MTMapReferenceStyle) -> [MTMapStyleVariant]?

    Parameters

    referenceStyle

    Reference style for which to get variants.

  • Returns ID of the current reference style.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getIdForCurrentReferenceStyle(completionHandler: ((Result<String, MTError>) -> Void)? = nil)

    Parameters

    completionHandler

    A handler block to execute when function finishes.

  • Returns ID for the provided reference style.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getId(
        for referenceStyle: MTMapReferenceStyle,
        completionHandler: ((Result<String, MTError>) -> Void)? = nil
    )

    Parameters

    referenceStyle

    Reference style for which to get id.

    completionHandler

    A handler block to execute when function finishes.

  • Returns ID of the current style variant, if it exists.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getIdForCurrentStyleVariant(completionHandler: ((Result<String, MTError>) -> Void)? = nil)

    Parameters

    completionHandler

    A handler block to execute when function finishes.

  • Returns id for the provided style variant.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getId(
        for styleVariant: MTMapStyleVariant,
        completionHandler: ((Result<String, MTError>) -> Void)? = nil
    )

    Parameters

    styleVariant

    Style variant for which to get id.

    completionHandler

    A handler block to execute when function finishes.

  • Returns name of the current reference style.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getNameForCurrentReferenceStyle(completionHandler: ((Result<String, MTError>) -> Void)? = nil)

    Parameters

    completionHandler

    A handler block to execute when function finishes.

  • Returns name of the provided reference style.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getName(
        for referenceStyle: MTMapReferenceStyle,
        completionHandler: ((Result<String, MTError>) -> Void)? = nil
    )

    Parameters

    referenceStyle

    Reference style for which to get name.

    completionHandler

    A handler block to execute when function finishes.

  • Returns name of the current style variant, if it exists.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getNameForCurrentStyleVariant(completionHandler: ((Result<String, MTError>) -> Void)? = nil)

    Parameters

    completionHandler

    A handler block to execute when function finishes.

  • Returns name for the provided style variant.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getName(
        for styleVariant: MTMapStyleVariant,
        completionHandler: ((Result<String, MTError>) -> Void)? = nil
    )

    Parameters

    styleVariant

    Style variant for which to get name.

    completionHandler

    A handler block to execute when function finishes.

  • Adds a source to the map.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func addSource(_ source: MTSource, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)

    Parameters

    source

    Source to be added.

  • Removes a source from the map.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func removeSource(_ source: MTSource, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)

    Parameters

    source

    Source to be removed.

  • Returns a boolean indicating whether a source is already added to the map.

    Declaration

    Swift

    @MainActor
    public func sourceExists(_ source: MTSource) -> Bool
  • Adds a layer to the map.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func addLayer(_ layer: MTLayer, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)

    Parameters

    layer

    Layer to be added.

  • Adds multiple layers to the map.

    Note

    All parent sources must be loaded prior to calling this method.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func addLayers(_ layers: [MTLayer], completionHandler: ((Result<Void, MTError>) -> Void)? = nil)

    Parameters

    layers

    Layers to be added.

  • Removes a layer from the map.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func removeLayer(_ layer: MTLayer, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)

    Parameters

    layer

    Layer to be removed.

  • Remove multiple layers from the map.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func removeLayers(_ layers: [MTLayer], completionHandler: ((Result<Void, MTError>) -> Void)? = nil)

    Parameters

    layers

    Layers to be removed.

  • Returns a boolean indicating whether a layer is already added to the map.

    Declaration

    Swift

    @MainActor
    public func layerExists(_ layer: MTLayer) -> Bool
  • Updates the map’s style object with a new value.

    Declaration

    Swift

    @MainActor
    public func setStyle(_ referenceStyle: MTMapReferenceStyle, styleVariant: MTMapStyleVariant?) async

    Parameters

    referenceStyle

    Desired reference map style.

    styleVariant

    Optional variant of the reference style.

  • Returns ID of the current reference style.

    Declaration

    Swift

    @MainActor
    public func getIdForCurrentReferenceStyle() async -> String
  • getId(for:) Asynchronous

    Returns ID for the provided reference style.

    Declaration

    Swift

    @MainActor
    public func getId(for referenceStyle: MTMapReferenceStyle) async -> String

    Parameters

    referenceStyle

    Reference style for which to get id.

  • Returns ID of the current style variant, if it exists.

    Declaration

    Swift

    @MainActor
    public func getIdForCurrentStyleVariant() async -> String?
  • getId(for:) Asynchronous

    Returns id for the provided style variant.

    Declaration

    Swift

    @MainActor
    public func getId(for styleVariant: MTMapStyleVariant) async -> String

    Parameters

    styleVariant

    Style variant for which to get id.

  • Returns name of the current reference style.

    Declaration

    Swift

    @MainActor
    public func getNameForCurrentReferenceStyle() async -> String
  • getName(for:) Asynchronous

    Returns name of the provided reference style.

    Declaration

    Swift

    @MainActor
    public func getName(for referenceStyle: MTMapReferenceStyle) async -> String

    Parameters

    referenceStyle

    Reference style for which to get name.

  • Returns name of the current style variant, if it exists.

    Declaration

    Swift

    @MainActor
    public func getNameForCurrentStyleVariant() async -> String?
  • getName(for:) Asynchronous

    Returns name for the provided style variant.

    Declaration

    Swift

    @MainActor
    public func getName(for styleVariant: MTMapStyleVariant) async -> String

    Parameters

    styleVariant

    Style variant for which to get name.

  • addSource(_:) Asynchronous

    Adds a source to the map.

    Throws

    A MTStyleError.sourceAlreadyExists if source with the same id is already added to the map.

    Declaration

    Swift

    @MainActor
    public func addSource(_ source: MTSource) async throws

    Parameters

    source

    Source to be added.

  • removeSource(_:) Asynchronous

    Removes a source from the map.

    Throws

    A MTStyleError.sourceNotFound if source does not exist on the map.

    Declaration

    Swift

    @MainActor
    public func removeSource(_ source: MTSource) async throws

    Parameters

    source

    Source to be removed.

  • addLayer(_:) Asynchronous

    Adds a layer to the map.

    Throws

    A MTStyleError.layerAlreadyExists if layer with the same id is already added to the map.

    Declaration

    Swift

    @MainActor
    public func addLayer(_ layer: MTLayer) async throws

    Parameters

    layer

    Layer to be added.

  • addLayers(_:) Asynchronous

    Adds multiple layers to the map.

    Note

    All parent sources must be loaded prior to calling this method.

    Declaration

    Swift

    @MainActor
    public func addLayers(_ layers: [MTLayer]) async throws

    Parameters

    layers

    Layers to be added.

  • removeLayer(_:) Asynchronous

    Removes a layer from the map.

    Throws

    A MTStyleError.layerNotFound if layer does not exist on the map.

    Declaration

    Swift

    @MainActor
    public func removeLayer(_ layer: MTLayer) async throws

    Parameters

    layer

    Layer to be removed.

  • removeLayers(_:) Asynchronous

    Removes multiple layers from the map.

    Declaration

    Swift

    @MainActor
    public func removeLayers(_ layers: [MTLayer]) async throws

    Parameters

    layers

    Layers to be removed.