Style

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.

<p> Note: Similar to a View object, a [Style] should only be read and modified from the main thread. </p>

class Style : StyleManagerInterface

Types

Companion
Link copied to clipboard

A convenience object to access the style ID strings of the professionally-designed map styles made by Mapbox.

object Companion
OnStyleLoaded
Link copied to clipboard

Callback to be invoked when a style has finished loading.

fun fun interface OnStyleLoaded

Functions

addImage
Link copied to clipboard

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, and line-pattern.

See https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-image See https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern See https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern

fun addImage(imageId: String, bitmap: Bitmap): Expected<Void, String>
fun addImage(imageId: String, image: Image): Expected<Void, String>
fun addImage(imageId: String, bitmap: Bitmap, sdf: Boolean): Expected<Void, String>
fun addImage(imageId: String, image: Image, sdf: Boolean): Expected<Void, String>
addStyleCustomGeometrySource
Link copied to clipboard

Adds a custom geometry to be used in the style. To add the data, implement the fetchTileFunction callback in the options and call setStyleCustomGeometrySourceTileData()

open override fun addStyleCustomGeometrySource(sourceId: String, options: CustomGeometrySourceOptions): Expected<Void, String>
addStyleCustomLayer
Link copied to clipboard

Adds a new style custom layer.

style-spec#layers

Runtime style layers are valid until they are either removed or a new style is loaded.

Note: Custom layers are only valid on OpenGL rendering backend. Attempting to add a custom layer on Metal rendering backend results in undefined behavior.

open override fun addStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition?): Expected<Void, String>
addStyleImage
Link copied to clipboard

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, and line-pattern.

See https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-image See https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern See https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern

open override fun addStyleImage(imageId: String, scale: Float, image: Image, sdf: Boolean, stretchX: List<ImageStretches>, stretchY: List<ImageStretches>, content: ImageContent?): Expected<Void, String>
addStyleLayer
Link copied to clipboard

Adds a new style layer.

See https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers

Runtime style layers are valid until they are either removed or a new style is loaded.

open override fun addStyleLayer(parameters: Value, position: LayerPosition?): Expected<Void, String>
addStyleSource
Link copied to clipboard
open override fun addStyleSource(sourceId: String, properties: Value): Expected<Void, String>
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
getStyleDefaultCamera
Link copied to clipboard

Returns the map style's default camera, if any, or a default camera otherwise. The map style default camera is defined as follows:

The style default camera is re-evaluated when a new style is loaded.

open override fun getStyleDefaultCamera(): CameraOptions
getStyleGeoJSONSourceClusterChildren
Link copied to clipboard

Returns the children of a cluster (on the next zoom level).

open override fun getStyleGeoJSONSourceClusterChildren(sourceId: String, clusterId: Int): Expected<MutableList<Feature>, String>

Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature).

open override fun getStyleGeoJSONSourceClusterExpansionZoom(sourceId: String, clusterId: Int): Expected<Byte, String>
getStyleGeoJSONSourceClusterLeaves
Link copied to clipboard

Returns all the leaves of a cluster (given its cluster_id), with pagination support: limit is the number of leaves to return (set to Infinity for all points), and offset is the amount of points to skip (for pagination).

open override fun getStyleGeoJSONSourceClusterLeaves(sourceId: String, clusterId: Int, limit: Int, offset: Int): Expected<MutableList<Feature>, String>
getStyleImage
Link copied to clipboard

Get an image from the style.

open override fun getStyleImage(imageId: String): Image?
getStyleJSON
Link copied to clipboard

Get the JSON serialization string of the current Mapbox Style in use.

open override fun getStyleJSON(): String
getStyleLayerProperties
Link copied to clipboard

Gets style layer properties.

open override fun getStyleLayerProperties(layerId: String): Expected<Value, String>
getStyleLayerProperty
Link copied to clipboard

Gets the value of style layer \p property.

open override fun getStyleLayerProperty(layerId: String, property: String): StylePropertyValue
getStyleLayers
Link copied to clipboard

Returns the existing style layers.

open override fun getStyleLayers(): List<StyleObjectInfo>
getStyleLightProperty
Link copied to clipboard

Gets the value of a style light property.

open override fun getStyleLightProperty(property: String): StylePropertyValue
getStyleSourceProperties
Link copied to clipboard

Gets style source parameters. In order to convert returned value to a json string please take a look at mapbox::common::ValueConverter.

open override fun getStyleSourceProperties(sourceId: String): Expected<Value, String>
getStyleSourceProperty
Link copied to clipboard

Gets the value of style source property.

open override fun getStyleSourceProperty(sourceId: String, property: String): StylePropertyValue
getStyleSources
Link copied to clipboard

Returns the existing style sources.

open override fun getStyleSources(): List<StyleObjectInfo>
getStyleSourcesAttribution
Link copied to clipboard

Returns the current sources metadata.

fun getStyleSourcesAttribution(): List<String>
getStyleTerrainProperty
Link copied to clipboard

Get the value of a style terrain property.

open override fun getStyleTerrainProperty(property: String): StylePropertyValue
getStyleTransition
Link copied to clipboard

Returns the map style's transition options. By default, the style parser will attempt to read the style default transition options, if any, fallbacking to an immediate transition otherwise. Transition options can be overriden via setStyleTransition, but the options are reset once a new style has been loaded.

The style transition is re-evaluated when a new style is loaded.

open override fun getStyleTransition(): TransitionOptions
getStyleURI
Link copied to clipboard

Get the URI of the current Mapbox Style in use.

open override fun getStyleURI(): String
hashCode
Link copied to clipboard
open override fun hashCode(): Int

Invalidate region for provided custom geometry source.

open override fun invalidateStyleCustomGeometrySourceRegion(sourceId: String, coordinateBounds: CoordinateBounds): Expected<Void, String>
invalidateStyleCustomGeometrySourceTile
Link copied to clipboard

Invalidate tile for provided custom geometry source.

open override fun invalidateStyleCustomGeometrySourceTile(sourceId: String, tileId: CanonicalTileID): Expected<Void, String>
isFullyLoaded
Link copied to clipboard

Return if the map is fully loaded

fun isFullyLoaded(): Boolean
isStyleLoaded
Link copied to clipboard

Check if the style is completely loaded.

open override fun isStyleLoaded(): Boolean
removeStyleImage
Link copied to clipboard

Removes an image from the style.

open override fun removeStyleImage(imageId: String): Expected<Void, String>
removeStyleLayer
Link copied to clipboard

Removes an existing style layer

Runtime style layers are valid until they are either removed or a new style is loaded.

open override fun removeStyleLayer(layerId: String): Expected<Void, String>
removeStyleSource
Link copied to clipboard

Removes an existing style source.

open override fun removeStyleSource(sourceId: String): Expected<Void, String>
setStyleCustomGeometrySourceTileData
Link copied to clipboard

Set tile data of a custom geometry.

open override fun setStyleCustomGeometrySourceTileData(sourceId: String, tileId: CanonicalTileID, featureCollection: MutableList<Feature>): Expected<Void, String>
setStyleJSON
Link copied to clipboard

Load the style from a provided JSON string.

attention This method should be called on the same thread where Map object is initialized.

open override fun setStyleJSON(json: String)
setStyleLayerProperties
Link copied to clipboard

Sets style layer metadata.

open override fun setStyleLayerProperties(layerId: String, properties: Value): Expected<Void, String>
setStyleLayerProperty
Link copied to clipboard

Sets a value to a style layer property.

open override fun setStyleLayerProperty(layerId: String, property: String, value: Value): Expected<Void, String>
setStyleLight
Link copied to clipboard

Sets the style global light source properties.

See https://docs.mapbox.com/mapbox-gl-js/style-spec/#light

open override fun setStyleLight(parameters: Value): Expected<Void, String>
setStyleLightProperty
Link copied to clipboard

Sets a value to the the style light property.

open override fun setStyleLightProperty(id: String, light: Value): Expected<Void, String>
setStyleSourceProperties
Link copied to clipboard

Sets style source parameters. This method can be used to perform batch update for a style source parameters. The structure of a provided parameters value must conform to \sa https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/ format for a corresponding source type. Modification of a source type https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#type is not allowed.

open override fun setStyleSourceProperties(sourceId: String, properties: Value): Expected<Void?, String?>
setStyleSourceProperty
Link copied to clipboard

Sets a value to a style source property.

open override fun setStyleSourceProperty(sourceId: String, property: String, value: Value): Expected<Void, String>
setStyleTerrain
Link copied to clipboard

Sets the style global terrain source properties.

open override fun setStyleTerrain(properties: Value): Expected<Void, String>
setStyleTerrainProperty
Link copied to clipboard

Gets the value of a style terrain property.

open override fun setStyleTerrainProperty(property: String, value: Value): Expected<Void, String>
setStyleTransition
Link copied to clipboard

Overrides the map style's transition options with user-provided options.

The style transition is re-evaluated when a new style is loaded.

open override fun setStyleTransition(transitionOptions: TransitionOptions)
setStyleURI
Link copied to clipboard

Load style from provided URI.

This is an asynchronous call. In order to get result of this operation please use OnStyleLoadedListener, OnStyleDataLoadedListener or ONMapLoadErrorListener. In case of successful style load you should get notified by OnStyleLoadedListener.

And in case of error @see MapLoadError#StyleLoadError will be generated.

\attention This method should be called on the same thread where @see Map object is initialized.

open override fun setStyleURI(uri: String)
styleLayerExists
Link copied to clipboard

Checks whether a given style layer exists.

Runtime style layers are valid until they are either removed or a new style is loaded.

open override fun styleLayerExists(layerId: String): Boolean
styleSourceExists
Link copied to clipboard

Checks whether a given style source exists.

open override fun styleSourceExists(sourceId: String): Boolean
subscribe
Link copied to clipboard

Subscribes an Observer to a provided list of event types. Observable will hold a strong reference to an Observer instance, therefore, in order to stop receiving notifications, caller must call unsubscribe with an Observer instance used for an initial subscription.

open override fun subscribe(observer: Observer, events: MutableList<String>)
toString
Link copied to clipboard
open override fun toString(): String
unsubscribe
Link copied to clipboard

Unsubscribes an Observer from all events.

open override fun unsubscribe(observer: Observer)

Unsubscribes an Observer from a provided list of event types.

open override fun unsubscribe(observer: Observer, events: MutableList<String>)
updateStyleImageSourceImage
Link copied to clipboard

Updates the image of an image style source.

See https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources-image

open override fun updateStyleImageSourceImage(sourceId: String, image: Image): Expected<Void, String>

Properties

fullyLoaded
Link copied to clipboard

true is style is fully loaded, false if a new style is being loaded

var fullyLoaded: Boolean