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.
Setting the style resets custom sources and layers, so make sure to wait for style to load (
styleDidUpdate) before adding them.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
referenceStyleDesired reference map style.
styleVariantOptional variant of the reference style.
completionHandlerA 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
referenceStyleReference 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
completionHandlerA 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
referenceStyleReference style for which to get id.
completionHandlerA 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
completionHandlerA 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
styleVariantStyle variant for which to get id.
completionHandlerA 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
completionHandlerA 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
referenceStyleReference style for which to get name.
completionHandlerA 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
completionHandlerA 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
styleVariantStyle variant for which to get name.
completionHandlerA handler block to execute when function finishes.
-
Removes a source from the map.
Declaration
Parameters
sourceSource 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 multiple layers to the map.
Note
All parent sources must be loaded prior to calling this method.Declaration
Parameters
layersLayers to be added.
-
Removes a layer from the map.
Declaration
Parameters
layerLayer to be removed.
-
Remove multiple layers from the map.
Declaration
Parameters
layersLayers 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 -
setStyle(_:AsynchronousstyleVariant: ) Updates the map’s style object with a new value.
Setting the style resets custom sources and layers, so make sure to wait for style to load (
styleDidUpdate) before adding them.Declaration
Swift
@MainActor public func setStyle(_ referenceStyle: MTMapReferenceStyle, styleVariant: MTMapStyleVariant?) asyncParameters
referenceStyleDesired reference map style.
styleVariantOptional variant of the reference style.
-
getIdForCurrentReferenceStyle()AsynchronousReturns 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 -> StringParameters
referenceStyleReference style for which to get id.
-
getIdForCurrentStyleVariant()AsynchronousReturns 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 -> StringParameters
styleVariantStyle variant for which to get id.
-
getNameForCurrentReferenceStyle()AsynchronousReturns 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 -> StringParameters
referenceStyleReference style for which to get name.
-
getNameForCurrentStyleVariant()AsynchronousReturns 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 -> StringParameters
styleVariantStyle variant for which to get name.
-
addSource(_:Asynchronous) Adds a source to the map.
Throws
AMTStyleError.sourceAlreadyExistsif source with the same id is already added to the map.Declaration
Swift
@MainActor public func addSource(_ source: MTSource) async throwsParameters
sourceSource to be added.
-
removeSource(_:Asynchronous) Removes a source from the map.
Throws
AMTStyleError.sourceNotFoundif source does not exist on the map.Declaration
Swift
@MainActor public func removeSource(_ source: MTSource) async throwsParameters
sourceSource to be removed.
-
addLayer(_:Asynchronous) Adds a layer to the map.
Throws
AMTStyleError.layerAlreadyExistsif layer with the same id is already added to the map.Declaration
Swift
@MainActor public func addLayer(_ layer: MTLayer) async throwsParameters
layerLayer 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 throwsParameters
layersLayers to be added.
-
removeLayer(_:Asynchronous) Removes a layer from the map.
Throws
AMTStyleError.layerNotFoundif layer does not exist on the map.Declaration
Swift
@MainActor public func removeLayer(_ layer: MTLayer) async throwsParameters
layerLayer to be removed.
-
removeLayers(_:Asynchronous) Removes multiple layers from the map.
Declaration
Swift
@MainActor public func removeLayers(_ layers: [MTLayer]) async throwsParameters
layersLayers to be removed.