loadStyle

fun loadStyle(style: String, onStyleLoaded: Style.OnStyleLoaded? = null)


fun loadStyle(styleExtension: StyleContract.StyleExtension, onStyleLoaded: Style.OnStyleLoaded? = null)

Loads the new map style built from the specified style DSL block. For example:

mapboxMap.loadStyle(style(Style.DARK) { +geoJsonSource(SOURCE_ID) { featureCollection(collection) } +symbolLayer(LAYER_ID, SOURCE_ID) { iconImage(IMAGE_ID) } }

** Important notes comparing to Maps v10 **:

  1. Parameter onMapLoadErrorListener was removed as it was not covering all the map / style loading errors. Now if you need to listen to those errors you have to register specific listener in advance, e.g. OnMapLoadErrorListener should now be registered with subscribeMapLoadingError; you could also subscribe to other events like subscribeStyleImageMissing or subscribeStyleImageRemoveUnused.

  2. Parameter styleTransitionOptions was removed from this overloaded method. Instead you have to add transition options in the DSL block:

mapboxMap.loadStyle(style(Style.DARK) { +transition { duration(100L) enablePlacementTransitions(false) } // other runtime styling }

Parameters

styleExtension

The style DSL block used to describe the style with runtime styling on top of it.

onStyleLoaded

callback triggered when the style is successfully loaded.