StyleManager
public class StyleManager
Style provides access to the APIs used to dynamically modify the map’s style. Use it to read and write layers, sources, and images. Obtain the Style instance for a MapView via MapView.mapboxMap.style.
Important
Style should only be used from the main thread.-
Adds a
layerto the mapThrows
StyleErrorif there is a problem adding the givenlayerat the givenposition.Declaration
Swift
public func addLayer(_ layer: Layer, layerPosition: LayerPosition? = nil) throwsParameters
layerThe layer to apply on the map
layerPositionPosition to add the layer in the stack of layers on the map. Defaults to the top layer.
-
Adds a persistent
layerto the map. Persistent layers are valid acrossstylechanges.Throws
StyleErrorif there is a problem adding the persistent layer.Declaration
Swift
public func addPersistentLayer(_ layer: Layer, layerPosition: LayerPosition? = nil) throwsParameters
layerThe layer to apply on the map
layerPositionPosition to add the layer in the stack of layers on the map. Defaults to the top layer.
-
Moves a
layerto a new layer position in the style.Throws
StyleErroron failure, orNSErrorwith a _domain of “com.mapbox.bindgen”Declaration
Swift
public func moveLayer(withId id: String, to position: LayerPosition) throwsParameters
layerIdThe layer to move
positionPosition to move the layer in the stack of layers on the map. Defaults to the top layer.
-
Gets a
layerfrom the mapThrows
StyleErrorif there is a problem getting the layer data.Throws
TypeConversionErroris there is a problem decoding the layer data to the giventype.Declaration
Swift
public func layer<T>(withId id: String, type: T.Type) throws -> T where T : LayerParameters
idThe id of the layer to be fetched
typeThe type of the layer that will be fetched
Return Value
The fully formed
layerobject of type equal totype -
Gets a
layerfrom the map.This function is useful if you do not know the concrete type of the layer you are fetching, or don’t need to know for your situation.
Throws
Type conversion errors
Declaration
Swift
public func layer(withId id: String) throws -> LayerParameters
layerIDThe id of the layer to be fetched
Return Value
The fully formed
layerobject. -
Updates a
layerthat exists in thestylealreadyThrows
TypeConversionErrorif there is a problem getting a layer data.Throws
StyleErrorif there is a problem updating the layer.Throws
An error when executing
updateblock.Declaration
Swift
public func updateLayer<T>(withId id: String, type: T.Type, update: (inout T) throws -> Void) throws where T: LayerParameters
ididentifier of layer to update
typeType of the layer
updateClosure that mutates a layer passed to it
-
Adds a
sourceto the mapThrows
StyleErrorif there is a problem adding thesource.Declaration
Swift
public func addSource(_ source: Source, dataId: String? = nil) throwsParameters
sourceThe source to add to the map.
identifierA unique source identifier.
dataIdAn optional data ID to filter
onSourceDataLoadedto only the specified data source. Applies only toGeoJSONSources. -
Retrieves a
sourcefrom the mapThrows
StyleErrorif there is a problem getting the source data.Throws
TypeConversionErrorif there is a problem decoding the source data to the giventype.Declaration
Swift
public func source<T>(withId id: String, type: T.Type) throws -> T where T : SourceParameters
idThe id of the source to retrieve
typeThe type of the source
Return Value
The fully formed
sourceobject of type equal totype. -
Retrieves a
sourcefrom the mapThis function is useful if you do not know the concrete type of the source you are fetching, or don’t need to know for your situation.
Throws
StyleErrorif there is a problem getting the source data.Declaration
Swift
public func source(withId id: String) throws -> SourceParameters
idThe id of the
sourceto retrieve.Return Value
The fully formed
sourceobject. -
Updates the
dataproperty of a givenGeoJSONSourcewith a new value.The update will be scheduled and applied on a GeoJSON serialization queue.
In order to capture events when actual data is drawn on the map please refer to Events API and listen to
onSourceDataLoaded(optionally pass thedataIdparameter to filter the events) oronMapLoadingErrorwithtype = metadataif data parsing error has occurred.Attention
This method is only effective with sources ofGeoJSONSourcetype, and cannot be used to update other source types.Declaration
Swift
public func updateGeoJSONSource(withId id: String, data: GeoJSONSourceData, dataId: String? = nil)Parameters
idThe identifier representing the GeoJSON source.
dataThe new data to be associated with the source.
dataIdAn optional data ID to filter
onSourceDataLoadedto only the specified data source. -
Updates the
dataproperty of a givenGeoJSONSourcewith a new value ofGeoJSONObject.The update will be scheduled and applied on a GeoJSON serialization queue.
In order to capture events when actual data is drawn on the map please refer to Events API and listen to
onSourceDataLoaded(optionally pass thedataIdparameter to filter the events) oronMapLoadingErrorwithtype = metadataif data parsing error has occurred.Attention
This method is only effective with sources ofGeoJSONSourcetype, and cannot be used to update other source types.Declaration
Swift
public func updateGeoJSONSource(withId id: String, geoJSON: GeoJSONObject, dataId: String? = nil)Parameters
idThe identifier representing the GeoJSON source.
geoJSONThe new GeoJSON to be associated with the source data. i.e. a feature or feature collection.
dataIdAn optional data ID to filter
onSourceDataLoadedto only the specified data source. -
Add additional features to a GeoJSON style source.
The add operation will be scheduled and applied on a GeoJSON serialization queue.
In order to capture events when actual data is drawn on the map please refer to Events API and listen to
onSourceDataLoaded(optionally pass thedataIdparameter to filter the events) oronMapLoadingErrorwithtype = metadataif data parsing error has occurred.Partially updating a GeoJSON source is not compatible with using shared cache and generated IDs. It is important to ensure that every feature in the GeoJSON style source, as well as the newly added feature, has a unique ID (or a unique promote ID if in use). Failure to provide unique IDs will result in a
map-loading-error.Note
The method allows the user to provide a data ID, which will be returned as the
dataIdparameter in thesource-data-loadedevent. However, it’s important to note that multiple partial updates can be queued for the same GeoJSON source when ongoing source parsing is taking place. In these cases, the partial updates will be applied to the source in batches. Only the data ID provided in the most recent call within each batch will be included in thesource-data-loadedevent. If no data ID is provided in the most recent call, the data ID in thesource-data-loadedevent will be null.Throws
StyleErrorif there is a problem adding features to the source.Declaration
Swift
public func addGeoJSONSourceFeatures(forSourceId sourceId: String, features: [Feature], dataId: String? = nil)Parameters
sourceIdThe identifier of the style source.
featuresAn array of GeoJSON features to be added to the source.
dataIdAn arbitrary string used to track the given GeoJSON data.
-
Update existing features in a GeoJSON style source.
The update operation will be scheduled and applied on a GeoJSON serialization queue.
In order to capture events when actual data is drawn on the map please refer to Events API and listen to
onSourceDataLoaded(optionally pass thedataIdparameter to filter the events) oronMapLoadingErrorwithtype = metadataif data parsing error has occurred.Partially updating a GeoJSON source is not compatible with using shared cache and generated IDs. It is important to ensure that every feature in the GeoJSON style source, as well as the newly added feature, has a unique ID (or a unique promote ID if in use). Failure to provide unique IDs will result in a
map-loading-error.Note
The method allows the user to provide a data ID, which will be returned as thedataIdparameter in thesource-data-loadedevent. However, it’s important to note that multiple partial updates can be queued for the same GeoJSON source when ongoing source parsing is taking place. In these cases, the partial updates will be applied to the source in batches. Only the data ID provided in the most recent call within each batch will be included in thesource-data-loadedevent. If no data ID is provided in the most recent call, the data ID in thesource-data-loadedevent will be null.Throws
StyleErrorif there is a problem updating features in the source.Declaration
Swift
public func updateGeoJSONSourceFeatures(forSourceId sourceId: String, features: [Feature], dataId: String? = nil)Parameters
sourceIdA style source identifier.
featuresThe GeoJSON features to be updated in the source.
dataIdAn arbitrary string used to track the given GeoJSON data.
-
Remove features from a GeoJSON style source.
The remove operation will be scheduled and applied on a GeoJSON serialization queue.
In order to capture events when actual data is drawn on the map please refer to Events API and listen to
onSourceDataLoaded(optionally pass thedataIdparameter to filter the events) oronMapLoadingErrorwithtype = metadataif an error has occurred.Partially updating a GeoJSON source is not compatible with using shared cache and generated IDs. It is important to ensure that every feature in the GeoJSON style source, as well as the newly added feature, has a unique ID (or a unique promote ID if in use). Failure to provide unique IDs will result in a
map-loading-error.Note
The method allows the user to provide a data ID, which will be returned as thedataIdparameter in thesource-data-loadedevent. However, it’s important to note that multiple partial updates can be queued for the same GeoJSON source when ongoing source parsing is taking place. In these cases, the partial updates will be applied to the source in batches. Only the data ID provided in the most recent call within each batch will be included in thesource-data-loadedevent. If no data ID is provided in the most recent call, the data ID in thesource-data-loadedevent will be null.Throws
StyleErrorif there is a problem removing features from the source.Declaration
Swift
public func removeGeoJSONSourceFeatures(forSourceId sourceId: String, featureIds: [String], dataId: String? = nil)Parameters
sourceIdA style source identifier.
featureIdsThe Ids of the features that need to be removed from the source.
dataIdAn arbitrary string used to track the given GeoJSON data.
-
trueif and only if the style JSON contents, the style specified sprite, and sources are all loaded, otherwise returnsfalse.Declaration
Swift
public var isStyleLoaded: Bool { get } -
MapStyle represents style configuration to load the style.
It comprises from a StyleURI or style JSON complemented by style import configuration.
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public var mapStyle: MapStyle? { get set } -
Get or set the style URI
Setting a new style is asynchronous. In order to get the result of this operation, listen to
MapEvents.styleDataLoaded,MapEvents.styleLoaded.Attention
This method should be called on the same thread where the MapboxMap object is initialized.Declaration
Swift
public var styleURI: StyleURI? { get set } -
Get or set the style via a JSON serialization string
Attention
This method should be called on the same thread where the MapboxMap object is initialized.Declaration
Swift
public var styleJSON: String { get set } -
The map
style‘s default camera, if any, or a default camera otherwise. The mapstyledefault camera is defined as follows:The
styledefault camera is re-evaluated when a newstyleis loaded. Values default to 0.0 if they are not defined in thestyle.Declaration
Swift
public var styleDefaultCamera: CameraOptions { get } -
Get or set the map
style‘s transition options.By default, the style parser will attempt to read the style default transition, if any, falling back to a 0.3 s transition otherwise.
Overridden transitions are reset once a new style has been loaded. To customize the transition used when switching styles, set this property after
MapEvents.Event.styleDataLoadedwherepayload type == "style"and beforeMapEvents.Event.styleDataLoadedwherepayload type == "sprite"and wherepayload type == "sources".See also
onNext(event:handler:)Declaration
Swift
public var styleTransition: TransitionOptions { get set } -
Returns the list containing information about existing style import objects.
Declaration
Swift
public var styleImports: [StyleObjectInfo] { get } -
Removes an existing style import.
Throws
Throws:
- An error describing why the operation was unsuccessful.
Declaration
Swift
public func removeStyleImport(for importId: String) throws -
Gets the style import schema.
Throws
Throws:
- A StyleError or decoding error if the operation was not successful.
Declaration
Swift
public func getStyleImportSchema(for importId: String) throws -> AnyReturn Value
- The style import schema, containing the default configurations for the style import, or a string describing an error if the operation was not successful.
-
Gets style import config.
Declaration
Swift
public func getStyleImportConfigProperties(for importId: String) throws -> [String : StylePropertyValue]Return Value
- The style import configuration or a string describing an error if the operation was not successful.
-
Gets the value of style import config.
Declaration
Swift
public func getStyleImportConfigProperty(for importId: String, config: String) throws -> StylePropertyValueReturn Value
- The style import configuration or a string describing an error if the operation was not successful.
-
Sets style import config. This method can be used to perform batch update for a style import configurations.
Throws
Throws:
- A string describing an error if the operation was not successful.
Declaration
Swift
public func setStyleImportConfigProperties(for importId: String, configs: [String : Any]) throws -
Sets a value to a style import config.
Throws
Throws:
- A string describing an error if the operation was not successful.
Declaration
Swift
public func setStyleImportConfigProperty(for importId: String, config: String, value: Any) throws
-
Adds a new style layer given its JSON properties
Runtime style layers are valid until they are either removed or a new style is loaded.
See
See Also: https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addLayer(with properties: [String : Any], layerPosition: LayerPosition?) throwsParameters
propertiesA JSON dictionary of style layer properties.
layerPositionPosition to add the layer in the stack of layers on the map. Defaults to the top layer.
-
Adds a new persistent style layer given its JSON properties
Persistent style layers remain valid across style reloads.
Throws
An error describing why the operation was unsuccessful
Declaration
Swift
public func addPersistentLayer(with properties: [String : Any], layerPosition: LayerPosition?) throwsParameters
propertiesA JSON dictionary of style layer properties
layerPositionPosition to add the layer in the stack of layers on the map. Defaults to the top layer.
-
Returns
trueif the id passed in is associated to a persistent layerDeclaration
Swift
public func isPersistentLayer(id: String) throws -> BoolParameters
idThe layer identifier to test
-
Adds a new persistent style custom layer.
Persistent style layers are valid across style reloads.
See
See Also: https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addPersistentCustomLayer(withId id: String, layerHost: CustomLayerHost, layerPosition: LayerPosition?) throwsParameters
idStyle layer id.
layerHostStyle custom layer host.
layerPositionPosition to add the layer in the stack of layers on the map. Defaults to the top layer.
-
Adds a new style custom layer.
Runtime style layers are valid until they are either removed or a new style is loaded.
See
See Also: https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addCustomLayer(withId id: String, layerHost: CustomLayerHost, layerPosition: LayerPosition?) throwsParameters
idStyle layer id.
layerHostStyle custom layer host.
layerPositionPosition to add the layer in the stack of layers on the map. Defaults to the top layer.
-
Removes an existing style layer
Runtime style layers are valid until they are either removed or a new style is loaded.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func removeLayer(withId id: String) throwsParameters
idIdentifier of the style layer to remove.
-
Checks whether a given style layer exists.
Runtime style layers are valid until they are either removed or a new style is loaded.
Declaration
Swift
public func layerExists(withId id: String) -> BoolParameters
idStyle layer identifier.
Return Value
trueif the given style layer exists,falseotherwise. -
The ordered list of the current style layers’ identifiers and types
Declaration
Swift
public var allLayerIdentifiers: [LayerInfo] { get }
-
Gets the value of style layer property.
Declaration
Swift
public func layerPropertyValue(for layerId: String, property: String) -> AnyParameters
layerIdStyle layer identifier.
propertyStyle layer property name.
Return Value
The value of the property in the layer with layerId.
-
Gets the value of style layer property.
Declaration
Swift
public func layerProperty(for layerId: String, property: String) -> StylePropertyValueParameters
layerIdStyle layer identifier.
propertyStyle layer property name.
Return Value
The value of the property in the layer with layerId.
-
Sets a JSON value to a style layer property.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setLayerProperty(for layerId: String, property: String, value: Any) throwsParameters
layerIdStyle layer identifier.
propertyStyle layer property name.
valueStyle layer property value.
-
Gets the default value of style layer property.
Declaration
Swift
public static func layerPropertyDefaultValue(for layerType: LayerType, property: String) -> StylePropertyValueParameters
layerTypeStyle layer type.
propertyStyle layer property name.
Return Value
The default value of the property for the layers with type layerType.
-
Gets the properties for a style layer.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func layerProperties(for layerId: String) throws -> [String : Any]Parameters
layerIdlayer id.
Return Value
JSON dictionary representing the layer properties
-
Sets style layer properties.
This method can be used to perform batch update for a style layer properties. The structure of a provided
propertiesvalue must conform to the format for a corresponding layer type.Modification of a layer identifier and/or layer type is not allowed.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setLayerProperties(for layerId: String, properties: [String : Any]) throwsParameters
layerIdStyle layer identifier.
propertiesJSON dictionary representing the updated layer properties.
-
Adds a new style source.
See
See Also: https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addSource(withId id: String, properties: [String : Any]) throwsParameters
idAn identifier for the style source.
propertiesA JSON dictionary of style source properties.
-
Removes an existing style source.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func removeSource(withId id: String) throwsParameters
idIdentifier of the style source to remove.
-
Checks whether a given style source exists.
Declaration
Swift
public func sourceExists(withId id: String) -> BoolParameters
idStyle source identifier.
Return Value
trueif the given source exists,falseotherwise. -
The ordered list of the current style sources’ identifiers and types.
Declaration
Swift
public var allSourceIdentifiers: [SourceInfo] { get }
-
Gets the value of style source property.
Declaration
Swift
public func sourceProperty(for sourceId: String, property: String) -> StylePropertyValueParameters
sourceIdStyle source identifier.
propertyStyle source property name.
Return Value
The value of the property in the source with sourceId.
-
Sets a value to a style source property.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setSourceProperty(for sourceId: String, property: String, value: Any) throwsParameters
sourceIdStyle source identifier.
propertyStyle source property name.
valueStyle source property value (JSON value)
-
Gets style source properties.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func sourceProperties(for sourceId: String) throws -> [String : Any]Parameters
sourceIdStyle source identifier
Return Value
JSON dictionary representing the layer properties
-
Sets style source properties.
This method can be used to perform batch update for a style source properties. The structure of a provided
propertiesvalue must conform to the format for a corresponding source type. Modification of a source type is not allowed.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setSourceProperties(for sourceId: String, properties: [String : Any]) throwsParameters
sourceIdStyle source identifier
propertiesA JSON dictionary of Style source properties
-
Gets the default value of style source property.
Declaration
Swift
public static func sourcePropertyDefaultValue(for sourceType: String, property: String) -> StylePropertyValueParameters
sourceTypeStyle source type.
propertyStyle source property name.
Return Value
The default value for the named property for the sources with type sourceType.
-
Updates the image of an image style source.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func updateImageSource(withId id: String, image: UIImage) throwsParameters
idStyle source identifier.
imageUIImage
-
Adds an image to be used in the style.
This API can also be used for updating an image. If the image id was already added, it gets replaced by the new image.
The image can be used in
icon-image,fill-pattern, andline-pattern.For more information on how
stretchXandstretchYparameters affect image stretching see this Mapbox GL-JS example.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addImage(_ image: UIImage, id: String, sdf: Bool = false, stretchX: [ImageStretches], stretchY: [ImageStretches], content: ImageContent? = nil) throwsParameters
imageImage to add.
idID of the image.
sdfOption to treat whether image is SDF(signed distance field) or not. Setting this to
trueallows template images to be recolored. The default value isfalse.stretchXAn array of two-element arrays, consisting of two numbers that represent the from position and the to position of areas that can be stretched horizontally.
stretchYAn array of two-element arrays, consisting of two numbers that represent the from position and the to position of areas that can be stretched vertically.
contentAn array of four numbers, with the first two specifying the left, top corner, and the last two specifying the right, bottom corner. If present, and if the icon uses icon-text-fit, the symbol’s text will be fit inside the content box.
-
Adds an image to be used in the style.
If the image has non-zero
UIImage.capInsetsit will be stretched accordingly, regardless of the value inUIImage.resizingMode.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addImage(_ image: UIImage, id: String, sdf: Bool = false, contentInsets: UIEdgeInsets = .zero) throwsParameters
imageImage to add.
idID of the image.
sdfOption to treat whether image is SDF(signed distance field) or not. Setting this to
trueallows template images to be recolored. The default value isfalse.contentInsetsThe distances the edges of content are inset from the image rectangle. If present, and if the icon uses icon-text-fit, the symbol’s text will be fit inside the content box.
-
Removes an image from the style.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func removeImage(withId id: String) throwsParameters
idID of the image to remove.
-
Checks whether an image exists.
Declaration
Swift
public func imageExists(withId id: String) -> BoolParameters
idThe identifier of the image.
Return Value
trueif the given image exists,falseotherwise. -
Get an image from the style.
Declaration
Swift
public func image(withId id: String) -> UIImage?Parameters
idID of the image.
Return Value
UIImage representing the data associated with the given ID, or nil if no image is associated with that ID.
-
The ordered list of the current style lights’ identifiers and types
Declaration
Swift
public var allLightIdentifiers: [LightInfo] { get } -
Gets the value of a style light property.
Declaration
Swift
public func lightProperty(for lightId: String, property: String) -> AnyParameters
lightThe unique identifier of the style light in lights list.
propertyThe style light property name.
-
Set global directional lightning.
Declaration
Swift
public func setLights(_ flatLight: FlatLight) throwsParameters
flatLightThe flat light source.
-
Set dynamic lightning.
Declaration
Swift
public func setLights(ambient ambientLight: AmbientLight, directional directionalLight: DirectionalLight) throwsParameters
ambientLightThe ambient light source.
directionalLightThe directional light source.
-
Sets the value of a style light property in lights list.
Throws
An error describing why the operation is unsuccessful.Declaration
Swift
public func setLightProperty(for lightId: String, property: String, value: Any) throwsParameters
idThe unique identifier of the style light in lights list.
propertyThe style light property name.
valueThe style light property value.
-
Removes terrain from style if it was set.
Declaration
Swift
public func removeTerrain() -
Sets the style global terrain source properties.
See
See Also: https://docs.mapbox.com/mapbox-gl-js/style-spec/#terrain
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setTerrain(properties: [String : Any]) throwsParameters
propertiesA dictionary of style terrain properties values, with their names as key.
-
Sets a value to the named style terrain property.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setTerrainProperty(_ property: String, value: Any) throwsParameters
propertyStyle terrain property name.
valueStyle terrain property value.
-
Gets the value of a style terrain property.
Declaration
Swift
public func terrainProperty(_ property: String) -> AnyParameters
propertyStyle terrain property name.
Return Value
Style terrain property value.
-
Gets the value of a style terrain property.
Declaration
Swift
public func terrainProperty(_ property: String) -> StylePropertyValueParameters
propertyStyle terrain property name.
Return Value
Style terrain property value.
-
Set the atmosphere of the style
Declaration
Swift
public func setAtmosphere(_ atmosphere: Atmosphere) throwsParameters
atmosphereAtmosphereobject describing the fog, space and stars. -
Remove the atmosphere of the style. No fog, space or stars would be rendered.
Declaration
Swift
public func removeAtmosphere() throws -
Set an explicit atmosphere properties
See
See Also style-spec/fog
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setAtmosphere(properties: [String : Any]) throwsParameters
propertiesA dictionary of style fog (aka atmosphere) properties values, with their names as key.
-
Sets the value of a style atmosphere property.
See
See Also style-spec/fog
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setAtmosphereProperty(_ property: String, value: Any) throwsParameters
propertyStyle atmosphere property name.
-
Gets the value of a style atmosphere property.
See
See Also: https://docs.mapbox.com/mapbox-gl-js/style-spec/fog/
Declaration
Swift
public func atmosphereProperty(_ property: String) -> StylePropertyValueParameters
propertyStyle atmosphere property name.
Return Value
Style atmosphere property value.
-
Adds a model to be used in the style. This API can also be used for updating a model. If the model for a given
modelIdwas already added, it gets replaced by the new model.The model can be used in
model-idproperty in model layer.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public func addStyleModel(modelId: String, modelUri: String) throwsParameters
modelIdAn identifier of the model.
modelUriA URI for the model.
-
Removes a model from the style.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public func removeStyleModel(modelId: String) throwsParameters
modelIdThe identifier of the model to remove.
-
Checks whether a model exists.
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public func hasStyleModel(modelId: String) -> BoolParameters
modelIdThe identifier of the model.
Return Value
True if model exists, false otherwise.
-
Adds a custom geometry to be used in the style.
To add the data, implement the fetchTileFunction callback in the options and call
setCustomGeometrySourceTileData.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func addCustomGeometrySource(withId id: String, options: CustomGeometrySourceOptions) throwsParameters
idStyle source identifier
optionsSettings for the custom geometry
-
Set tile data of a custom geometry.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func setCustomGeometrySourceTileData(forSourceId sourceId: String, tileId: CanonicalTileID, features: [Feature]) throwsParameters
sourceIdStyle source identifier
tileIdIdentifier of the tile
featuresAn array of features to add
-
Invalidate tile for provided custom geometry source.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func invalidateCustomGeometrySourceTile(forSourceId sourceId: String, tileId: CanonicalTileID) throwsParameters
sourceIdStyle source identifier
tileIdIdentifier of the tile
-
Invalidate region for provided custom geometry source.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
public func invalidateCustomGeometrySourceRegion(forSourceId sourceId: String, bounds: CoordinateBounds) throwsParameters
sourceIdStyle source identifier
boundsCoordinate bounds.
-
Note! This is an experimental feature. It can be changed or removed in future versions. Adds a custom raster source to be used in the style. To add the data, implement the
fetchTileFunctioncallback in the options and callsetCustomRasterSourceTileData(forSourceId:tileId:image:). Note: Functions provided inCustomRasterSourceOptionsfor fetching & cancelling tiles are executed on worker threads.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
@_spi(Experimental) public func addCustomRasterSource(forSourceId sourceId: String, options: CustomRasterSourceOptions) throwsParameters
sourceIdA Style source identifier
optionsThe
custom raster source optionsfor the custom raster source. -
Note! This is an experimental feature. It can be changed or removed in future versions. Set tile data for a raster tile. For custom raster source, we accept 32-bit RGBA data format. This method can be used in conjunction with
fetchTileFunctionprovided inCustomRasterSourceOptions, i.e., fetch tile fetches the required data and then sets the data for the tile using this API. Note: This API should be called from main thread.Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
@_spi(Experimental) public func setCustomRasterSourceTileData(forSourceId sourceId: String, tileId: CanonicalTileID, image: UIImage) throwsParameters
sourceIdA Style source identifier
tileIdA
canonicalTileIdof the tile.squareImagecontent of the tile. -
Note! This is an experimental feature. It can be changed or removed in future versions. Invalidate tile for provided custom raster source. This will make the source re-fetch the tile.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
@_spi(Experimental) public func invalidateCustomRasterSourceTile(forSourceId sourceId: String, tileId: CanonicalTileID) throwsParameters
sourceIdA Style source identifier
tileIdA
canonicalTileIdof the tile. -
Note! This is an experimental feature. It can be changed or removed in future versions. Invalidates all the tiles in the given region for the provided custom raster source.
Throws
An error describing why the operation was unsuccessful.
Declaration
Swift
@_spi(Experimental) public func invalidateCustomRasterSourceRegion(forSourceId sourceId: String, bounds: CoordinateBounds) throwsParameters
sourceIdA Style source identifier
boundsA
coordinateBoundsobject. -
This function creates an expression that will localize the
textFieldproperty of aSymbolLayerDeclaration
Swift
public func localizeLabels(into locale: Locale, forLayerIds layerIds: [String]? = nil) throwsParameters
localeThe
Localeto update the map tolayerIdsAn optional list of ids that need to be localized. If
nilis provided, all layers will be updated
-
Sets the projection.
Throws
StyleErrorif the projection could not be applied.Declaration
Swift
public func setProjection(_ projection: StyleProjection) throwsParameters
projectionThe
StyleProjectionto apply to the style. -
The current projection.
Declaration
Swift
public var projection: StyleProjection { get }
StyleManager Class Reference