Style

public class Style
extension Style: AnnotationStyleDelegate

Undocumented

  • Undocumented

    Declaration

    Swift

    public private(set) weak var styleManager: StyleManager! { get }
  • Undocumented

    Declaration

    Swift

    public init(with styleManager: StyleManager)
  • URL of the style currently displayed in the receiver.

    The URL may be a full HTTP or HTTPS URL ,a Mapbox style URL (mapbox://styles/{user}/{style}), or a URL for a style JSON file.

    If you set this property to nil, the receiver will use the default style and this property will automatically be set to that style’s URL.

    Declaration

    Swift

    public var styleURL: StyleURL { get set }
  • Adds a layer to the map

    Declaration

    Swift

    @discardableResult
    public func addLayer<T>(layer: T, layerPosition: LayerPosition? = nil) -> Result<Bool, LayerError> where T : Layer

    Parameters

    layer

    The layer to apply on the map

    Return Value

    If operation successful, returns a true as part of the Result success case. Else, returns a LayerError in the Result failure case.

  • Gets a layer from the map

    Declaration

    Swift

    public func getLayer<T>(with layerID: String, type: T.Type) -> Result<T, LayerError> where T : Layer

    Parameters

    layerID

    The id of the layer to be fetched

    type

    The type of the layer that will be fetched

    Return Value

    The fully formed layer object of type equal to type is returned as part of the Results success case if the operation is successful. Else, returns a LayerError as part of the Result failure case.

  • Add a given UIImage to the map style’s sprite, or updates the given image in the sprite if it already exists.

    You must call this method after the map’s style has finished loading in order to set any image or pattern properties on a style layer.

    Declaration

    Swift

    @discardableResult
    public func setStyleImage(image: UIImage,
                              with identifier: String,
                              sdf: Bool = false,
                              stretchX: [ImageStretches] = [],
                              stretchY: [ImageStretches] = [],
                              scale: CGFloat,
                              imageContent: ImageContent? = nil) -> Result<Bool, ImageError>

    Parameters

    image

    The image to be added to the map style’s sprite.

    identifier

    The name of the image the map style’s sprite will use for identification.

    sdf

    Whether or not the image is treated as a signed distance field. Defaults to false.

    stretchX

    The array of horizontal image stretch areas. Defaults to an empty array.

    stretchY

    The array of vertical image stretch areas. Defaults to an empty array.

    scale

    The scale factor for the image.

    imageContent

    The ImageContent which describes where text can be fit into an image. By default, this is nil.

    Return Value

    A boolean associated with a Result type if the operation is successful. Otherwise, this will return a StyleError as part of the Result failure case.

  • Undocumented

    Declaration

    Swift

    public func getStyleImage(with identifier: String) -> Image?
  • Remove a style layer from the map with specific id.

    Declaration

    Swift

    public func removeStyleLayer(forLayerId: String) -> Result<Bool, LayerError>

    Return Value

    A boolean associated with a Result type if the operation is successful. Otherwise, this will return a LayerError as part of the Result failure case.

  • Adds a source to the map

    Declaration

    Swift

    @discardableResult
    public func addSource<T>(source: T, identifier: String) -> Result<Bool, SourceError> where T : Source

    Parameters

    source

    The source to add to the map.

    identifier

    A unique source identifier.

    Return Value

    If operation successful, returns a true as part of the Result success case. Else, returns a SourceError in the Result failure case.

  • Retrieves a source from the map

    Declaration

    Swift

    public func getSource<T>(identifier: String, type: T.Type) -> Result<T, SourceError> where T : Source

    Parameters

    identifier

    The id of the source to retrieve

    type

    The type of the source

    Return Value

    The fully formed source object of type equal to type is returned as part of the Results success case if the operation is successful. Else, returns a SourceError as part of the Result failure case.

  • Set a source property for a given source to an updated value.

    Declaration

    Swift

    @discardableResult
    public func updateSourceProperty(id: String, property: String, value: [String : Any]) -> Result<Bool, SourceError>

    Parameters

    id

    The identifier representing the source.

    property

    The name of the source property to change.

    value

    The new value to for the property.

    Return Value

    If operation successful, returns a true as part of the Result success case. Else, returns a SourceError in the Result failure case.

  • Updates the data property of a given GeoJSONSource with a new value conforming to the GeoJSONObject protocol.

    Note

    This method is only effective with sources of GeoJSONSource type, and should not be used to update other source types.

    Declaration

    Swift

    public func updateGeoJSON<T>(for sourceIdentifier: String, with geoJSON: T) -> Result<Bool, SourceError> where T : GeoJSONObject

    Parameters

    sourceIdentifier

    The identifier representing the GeoJSON source.

    geoJSON

    The new GeoJSON to be associated with the source data.

    Return Value

    If operation successful, returns a true as part of the Result success case. Else, returns an Error in the Result failure case.

  • Sets a terrain on the style

    Declaration

    Swift

    @discardableResult
    public func setTerrain(_ terrain: Terrain) -> Result<Bool, TerrainError>

    Parameters

    terrain

    The Terrain that should be rendered

    Return Value

    Result type with .success if terrain is successfully applied. TerrainError otherwise.

  • Remove a source with a specified identifier from the map.

    Declaration

    Swift

    public func removeSource(for sourceID: String) -> Result<Bool, SourceError>

    Parameters

    sourceID

    The unique identifer representing the source to be removed.

    Return Value

    If operation successful, returns a true as part of the Result success case. Else, returns a SourceError in the Result failure case.

  • Add a light object to the map’s style

    Declaration

    Swift

    public func addLight(_ light: Light) -> Result<Bool, LightError>

    Parameters

    light

    The Light object to be applied to the style.

    Return Value

    IF operation successful, returns a true as part of the Result. Else returns a LightError.

  • Updates a layer that exists in the style already

    Declaration

    Swift

    @discardableResult
    public func updateLayer<T>(id: String, type: T.Type, update: (inout T) -> Void) -> Result<Bool, LayerError> where T : Layer

    Parameters

    id

    identifier of layer to update

    type

    Type of the layer

    update

    Closure that mutates a layer passed to it

    Return Value

    Result type with .success if update is successful, LayerError otherwise