RoutoStyle

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 getStyle(onStyleLoaded) method on MapboxMap.

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

Types

Link copied to clipboard
object Companion

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

Link copied to clipboard
fun interface OnStyleLoaded

Callback to be invoked when a style has finished loading.

Functions

Link copied to clipboard
fun addGeoJSONSourceFeatures(sourceId: String, dataId: String, features: List<Feature>): Expected<String, None>

Add features to the GeoJSON source. Call may take significant time for parsing and marshalling depending on the data size. Direct method use is not recommended, consider using GeoJsonSource.addGeoJSONSourceFeatures instead.

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

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.

Link copied to clipboard
fun addPersistentStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition?): Expected<String, None>

Adds a new style custom layer.

Link copied to clipboard
fun addPersistentStyleLayer(properties: Value, layerPosition: LayerPosition?): Expected<String, None>

Adds a new style layer.

Link copied to clipboard
fun addStyleCustomGeometrySource(sourceId: String, options: CustomGeometrySourceOptions): Expected<String, None>

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

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

Adds a new style custom layer.

Link copied to clipboard
fun addStyleCustomRasterSource(sourceId: String, options: CustomRasterSourceOptions): Expected<String, None>

Note! This is an experimental feature. It can be changed or removed in future versions.

Link copied to clipboard
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. This API can also be used for updating an image. If the image id was already added, it gets replaced by the new image.

Link copied to clipboard
fun addStyleLayer(parameters: Value, position: LayerPosition?): Expected<String, None>

Adds a new style layer.

Link copied to clipboard
fun addStyleModel(modelId: String, modelUri: String): Expected<String, None>

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 modelId was already added, it gets replaced by the new model.

Link copied to clipboard
fun addStyleSource(sourceId: String, properties: Value): Expected<String, None>

Adds a new style source.

Link copied to clipboard
fun getStyleAtmosphereProperty(property: String): StylePropertyValue

Gets the value of a style atmosphere property.

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

Get an image from the style.

Link copied to clipboard
fun getStyleImportConfigProperties(importId: String): Expected<String, HashMap<String, StylePropertyValue>>

Gets style import config.

Link copied to clipboard
fun getStyleImportConfigProperty(importId: String, config: String): Expected<String, StylePropertyValue>

Gets the value of style import config.

Link copied to clipboard
fun getStyleImports(): List<StyleObjectInfo>

Returns the existing style imports.

Link copied to clipboard
fun getStyleImportSchema(importId: String): Expected<String, Value>

Gets style import schema.

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

Gets style layer properties.

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

Gets the value of style layer property.

Link copied to clipboard
fun getStyleLightProperty(id: String, property: String): StylePropertyValue

Gets the value of the style light property.

Link copied to clipboard
fun getStyleLights(): MutableList<StyleObjectInfo>

Gets added lights to the style.

Link copied to clipboard
fun getStyleProjectionProperty(property: String): StylePropertyValue

Gets the value of a style projection property.

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

Gets style source parameters. In order to convert returned value to a json string please take a look at Value.toJson.

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

Gets the value of style source property.

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

Get the value of a style terrain property.

Link copied to clipboard
fun getStyleTransition(): TransitionOptions

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 overridden via setStyleTransition, but the options are reset once a new style has been loaded.

Link copied to clipboard

Checks whether an image exists.

Link copied to clipboard

Checks whether a model exists.

fun invalidateStyleCustomGeometrySourceRegion(sourceId: String, coordinateBounds: CoordinateBounds): Expected<String, None>

Invalidate region for provided custom geometry source.

Link copied to clipboard
fun invalidateStyleCustomGeometrySourceTile(sourceId: String, tileId: CanonicalTileID): Expected<String, None>

Invalidate tile for provided custom geometry source.

Link copied to clipboard
fun invalidateStyleCustomRasterSourceRegion(sourceId: String, bounds: CoordinateBounds): Expected<String, None>

Note! This is an experimental feature. It can be changed or removed in future versions.

Link copied to clipboard
fun invalidateStyleCustomRasterSourceTile(sourceId: String, tileId: CanonicalTileID): Expected<String, None>

Note! This is an experimental feature. It can be changed or removed in future versions.

Link copied to clipboard
fun isStyleLayerPersistent(layerId: String): Expected<String, Boolean>

Checks if a style layer is persistent.

Link copied to clipboard

Check if the style is completely loaded.

Link copied to clipboard

Whether the Style instance is valid.

Link copied to clipboard
fun moveStyleLayer(layerId: String, layerPosition: LayerPosition?): Expected<String, None>

Moves an existing style layer.

Link copied to clipboard
fun removeGeoJSONSourceFeatures(sourceId: String, dataId: String, featureIds: List<String>): Expected<String, None>

Remove features from the GeoJSON source. Call may take significant time for parsing and marshalling depending on the data size. Direct method use is not recommended, consider using GeoJsonSource.removeGeoJSONSourceFeatures instead.

Link copied to clipboard
fun removeStyleImage(imageId: String): Expected<String, None>

Removes an image from the style.

Link copied to clipboard
fun removeStyleImport(importId: String): Expected<String, None>

Removes an existing style import.

Link copied to clipboard
fun removeStyleLayer(layerId: String): Expected<String, None>

Removes an existing style layer

Link copied to clipboard
fun removeStyleModel(modelId: String): Expected<String, None>

Removes a model from the style.

Link copied to clipboard
fun removeStyleSource(sourceId: String): Expected<String, None>

Removes an existing style source.

Link copied to clipboard
fun setStyleAtmosphere(properties: Value): Expected<String, None>

Sets the style global atmosphere properties.

Link copied to clipboard
fun setStyleAtmosphereProperty(property: String, value: Value): Expected<String, None>

Sets a value to the the style atmosphere property.

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

Set tile data of a custom geometry.

Link copied to clipboard
fun setStyleCustomRasterSourceTileData(sourceId: String, tileId: CanonicalTileID, image: Image?): Expected<String, None>

Note! This is an experimental feature. It can be changed or removed in future versions.

Link copied to clipboard
fun setStyleGeoJSONSourceData(sourceId: String, dataId: String, data: GeoJSONSourceData): Expected<String, None>

Set geojson source data. Call may take significant time for parsing and marshalling depending on the data size. Direct method use is not recommended, consider using GeoJsonSource.geometry, GeoJsonSource.feature, GeoJsonSource.featureCollection, GeoJsonSource.data, GeoJsonSource.url instead.

Link copied to clipboard
fun setStyleImportConfigProperties(importId: String, configs: HashMap<String, Value>): Expected<String, None>

Sets style import config. This method can be used to perform batch update for a style import configurations.

Link copied to clipboard
fun setStyleImportConfigProperty(importId: String, config: String, value: Value): Expected<String, None>

Sets a value to a style import config.

Link copied to clipboard
fun setStyleLayerProperties(layerId: String, properties: Value): Expected<String, None>

Sets style layer metadata.

Link copied to clipboard
fun setStyleLayerProperty(layerId: String, property: String, value: Value): Expected<String, None>

Sets a value to a style layer property.

Link copied to clipboard
fun setStyleLightProperty(id: String, property: String, value: Value): Expected<String, None>

Sets a value to the light property.

Link copied to clipboard
fun setStyleLights(lights: Value): Expected<String, None>

Sets lights to the style.

Link copied to clipboard
fun setStyleProjection(properties: Value): Expected<String, None>

Sets the map's projection. If called with null, the map will reset to Mercator.

Link copied to clipboard
fun setStyleProjectionProperty(property: String, value: Value): Expected<String, None>

Sets a value to the the style projection property.

Link copied to clipboard
fun setStyleSourceProperties(sourceId: String, properties: Value): Expected<String, None>

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 Style Specification - 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.

Link copied to clipboard
fun setStyleSourceProperty(sourceId: String, property: String, value: Value): Expected<String, None>

Sets a value to a style source property.

Link copied to clipboard
fun setStyleTerrain(properties: Value): Expected<String, None>

Sets the style global terrain source properties.

Link copied to clipboard
fun setStyleTerrainProperty(property: String, value: Value): Expected<String, None>

Sets the value of a style terrain property.

Link copied to clipboard
fun setStyleTransition(transitionOptions: TransitionOptions)

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

Link copied to clipboard

Checks whether a given style layer exists.

Link copied to clipboard

Checks whether a given style source exists.

Link copied to clipboard
fun updateGeoJSONSourceFeatures(sourceId: String, dataId: String, features: List<Feature>): Expected<String, None>

Update features in the GeoJSON source. Call may take significant time for parsing and marshalling depending on the data size. Direct method use is not recommended, consider using GeoJsonSource.updateGeoJSONSourceFeatures instead.

Link copied to clipboard
fun updateStyleImageSourceImage(sourceId: String, image: Image): Expected<String, None>

Updates the image of an image style source.

Properties

Link copied to clipboard

the pixel ratio of the device

Link copied to clipboard
val styleDefaultCamera: CameraOptions

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

Link copied to clipboard

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

Link copied to clipboard
val styleLayers: List<StyleObjectInfo>

Returns the existing style layers.

Link copied to clipboard
val styleSources: List<StyleObjectInfo>

Returns the existing style sources.

Link copied to clipboard

Get the styleURI of the current Mapbox Style in use.