Style

class Style : StyleInterface

The general class to interact with Styles in the Modular Mapbox Maps SDK for Android. It exposes the entry point for all methods related to the Style. You cannot instantiate Style object directly, rather, you must obtain one from the getStyleAsync() method on MapboxMap.

Note: Similar to a View object, a Style should only be read and modified from the main thread.

Types

Companion
Link copied to clipboard
object Companion
A convenience object to access the style ID strings of the professionally-designed map styles made by Mapbox.
OnStyleLoaded
Link copied to clipboard
fun fun interface OnStyleLoaded
Callback to be invoked when a style has finished loading.

Functions

addImage
Link copied to clipboard
open override fun addImage(imageId: String, bitmap: Bitmap): Expected<String, None>
Adds an image to be used in the style.
fun addImage(imageId: String, image: Image): Expected<String, None>
Adds an image to be used in the style.
fun addImage(imageId: String, bitmap: Bitmap, sdf: Boolean): Expected<String, None>
Adds an image to be used in the style.
fun addImage(imageId: String, image: Image, sdf: Boolean): Expected<String, None>
Adds an image to be used in the style.
addPersistentStyleCustomLayer
Link copied to clipboard
open override fun addPersistentStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition?): Expected<String, None>
Adds a new style custom layer.
addPersistentStyleLayer
Link copied to clipboard
open override fun addPersistentStyleLayer(properties: Value, layerPosition: LayerPosition?): Expected<String, None>
Adds a new style layer.
addStyleCustomGeometrySource
Link copied to clipboard
open override fun addStyleCustomGeometrySource(sourceId: String, options: CustomGeometrySourceOptions): Expected<String, None>
Adds a custom geometry to be used in the style.
addStyleCustomLayer
Link copied to clipboard
open override fun addStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition?): Expected<String, None>
Adds a new style custom layer.
addStyleImage
Link copied to clipboard
open override fun addStyleImage(imageId: String, scale: Float, image: Image, sdf: Boolean, stretchX: List<ImageStretches>, stretchY: List<ImageStretches>, content: ImageContent?): Expected<String, None>
Adds an image to be used in the style.
addStyleLayer
Link copied to clipboard
open override fun addStyleLayer(parameters: Value, position: LayerPosition?): Expected<String, None>
Adds a new style layer.
addStyleSource
Link copied to clipboard
open override fun addStyleSource(sourceId: String, properties: Value): Expected<String, None>
Adds a new style source.
equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
getStyleDefaultCamera
Link copied to clipboard
open override fun getStyleDefaultCamera(): CameraOptions
Returns the map style's default camera, if any, or a default camera otherwise.
getStyleImage
Link copied to clipboard
open override fun getStyleImage(imageId: String): Image?
Get an image from the style.
getStyleJSON
Link copied to clipboard
open override fun getStyleJSON(): String
Get the JSON serialization string of the current Mapbox Style in use.
getStyleLayerProperties
Link copied to clipboard
open override fun getStyleLayerProperties(layerId: String): Expected<String, Value>
Gets style layer properties.
getStyleLayerProperty
Link copied to clipboard
open override fun getStyleLayerProperty(layerId: String, property: String): StylePropertyValue
Gets the value of style layer \p property.
getStyleLayers
Link copied to clipboard
open override fun getStyleLayers(): List<StyleObjectInfo>
Returns the existing style layers.
getStyleLightProperty
Link copied to clipboard
open override fun getStyleLightProperty(property: String): StylePropertyValue
Gets the value of a style light property.
getStyleSourceProperties
Link copied to clipboard
open override fun getStyleSourceProperties(sourceId: String): Expected<String, Value>
Gets style source parameters.
getStyleSourceProperty
Link copied to clipboard
open override fun getStyleSourceProperty(sourceId: String, property: String): StylePropertyValue
Gets the value of style source property.
getStyleSources
Link copied to clipboard
open override fun getStyleSources(): List<StyleObjectInfo>
Returns the existing style sources.
getStyleSourcesAttribution
Link copied to clipboard
fun getStyleSourcesAttribution(): List<String>
Returns the current sources metadata.
getStyleTerrainProperty
Link copied to clipboard
open override fun getStyleTerrainProperty(property: String): StylePropertyValue
Get the value of a style terrain property.
getStyleTransition
Link copied to clipboard
open override fun getStyleTransition(): TransitionOptions
Returns the map style's transition options.
getStyleURI
Link copied to clipboard
open override fun getStyleURI(): String
Get the URI of the current Mapbox Style in use.
hashCode
Link copied to clipboard
open fun hashCode(): Int
hasStyleImage
Link copied to clipboard
open override fun hasStyleImage(imageId: String): Boolean
Checks whether an image exists.
open override fun invalidateStyleCustomGeometrySourceRegion(sourceId: String, coordinateBounds: CoordinateBounds): Expected<String, None>
Invalidate region for provided custom geometry source.
invalidateStyleCustomGeometrySourceTile
Link copied to clipboard
open override fun invalidateStyleCustomGeometrySourceTile(sourceId: String, tileId: CanonicalTileID): Expected<String, None>
Invalidate tile for provided custom geometry source.
isStyleLayerPersistent
Link copied to clipboard
open override fun isStyleLayerPersistent(layerId: String): Expected<String, Boolean>
Checks if a style layer is persistent.
isStyleLoaded
Link copied to clipboard
open override fun isStyleLoaded(): Boolean
Check if the style is completely loaded.
moveStyleLayer
Link copied to clipboard
open override fun moveStyleLayer(layerId: String, layerPosition: LayerPosition?): Expected<String, None>
Moves an existing style layer.
removeStyleImage
Link copied to clipboard
open override fun removeStyleImage(imageId: String): Expected<String, None>
Removes an image from the style.
removeStyleLayer
Link copied to clipboard
open override fun removeStyleLayer(layerId: String): Expected<String, None>
Removes an existing style layerRuntime style layers are valid until they are either removed or a new style is loaded.
removeStyleSource
Link copied to clipboard
open override fun removeStyleSource(sourceId: String): Expected<String, None>
Removes an existing style source.
setStyleCustomGeometrySourceTileData
Link copied to clipboard
open override fun setStyleCustomGeometrySourceTileData(sourceId: String, tileId: CanonicalTileID, featureCollection: MutableList<Feature>): Expected<String, None>
Set tile data of a custom geometry.
setStyleJSON
Link copied to clipboard
open override fun setStyleJSON(json: String)
Load the style from a provided JSON string.
setStyleLayerProperties
Link copied to clipboard
open override fun setStyleLayerProperties(layerId: String, properties: Value): Expected<String, None>
Sets style layer metadata.
setStyleLayerProperty
Link copied to clipboard
open override fun setStyleLayerProperty(layerId: String, property: String, value: Value): Expected<String, None>
Sets a value to a style layer property.
setStyleLight
Link copied to clipboard
open override fun setStyleLight(parameters: Value): Expected<String, None>
Sets the style global light source properties.
setStyleLightProperty
Link copied to clipboard
open override fun setStyleLightProperty(id: String, light: Value): Expected<String, None>
Sets a value to the the style light property.
setStyleSourceProperties
Link copied to clipboard
open override fun setStyleSourceProperties(sourceId: String, properties: Value): Expected<String, None>
Sets style source parameters.
setStyleSourceProperty
Link copied to clipboard
open override fun setStyleSourceProperty(sourceId: String, property: String, value: Value): Expected<String, None>
Sets a value to a style source property.
setStyleTerrain
Link copied to clipboard
open override fun setStyleTerrain(properties: Value): Expected<String, None>
Sets the style global terrain source properties.
setStyleTerrainProperty
Link copied to clipboard
open override fun setStyleTerrainProperty(property: String, value: Value): Expected<String, None>
Gets the value of a style terrain property.
setStyleTransition
Link copied to clipboard
open override fun setStyleTransition(transitionOptions: TransitionOptions)
Overrides the map style's transition options with user-provided options.
setStyleURI
Link copied to clipboard
open override fun setStyleURI(uri: String)
Load style from provided URI.
styleLayerExists
Link copied to clipboard
open override fun styleLayerExists(layerId: String): Boolean
Checks whether a given style layer exists.
styleSourceExists
Link copied to clipboard
open override fun styleSourceExists(sourceId: String): Boolean
Checks whether a given style source exists.
subscribe
Link copied to clipboard
open override fun subscribe(observer: Observer, events: MutableList<String>)
Subscribes an Observer to a provided list of event types.
toString
Link copied to clipboard
open fun toString(): String
unsubscribe
Link copied to clipboard
open override fun unsubscribe(observer: Observer)
Unsubscribes an Observer from all events.
open override fun unsubscribe(observer: Observer, events: MutableList<String>)
Unsubscribes an Observer from a provided list of event types.
updateStyleImageSourceImage
Link copied to clipboard
open override fun updateStyleImageSourceImage(sourceId: String, image: Image): Expected<String, None>
Updates the image of an image style source.

Properties

pixelRatio
Link copied to clipboard
open override val pixelRatio: Float
the scale ratio of the style, default the device pixel ratio