load Style
Loads the new map style either from a specified URI or from a JSON both represented as String.
URI can take the following forms:
Constants: load one of the bundled styles in Style.
mapbox://styles/<user>/<style>
: loads the style from a Mapbox account. user is your username. style is the ID of your custom style created in Mapbox Studio.http://...
orhttps://...
: loads the style over the Internet from any web server.asset://...
: loads the style from the APK assets directory. This is used to load a style bundled with your app.file://...
: loads the style from a file path. This is used to load a style from disk.
If style is not the valid URI - it will be treated as style JSON string.
** Important notes comparing to Maps v10 **:
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.Parameter
styleTransitionOptions
was removed from this overloaded method. In order to apply it you should use more granular overloaded loadStyle taking StyleContract.StyleExtension and add transition options in DSL block:
mapboxMap.loadStyle(style(Style.DARK) { +transition { duration(100L) enablePlacementTransitions(false) } // other runtime styling }
Parameters
specified URI or from JSON both represented as String.
callback triggered when the style is successfully loaded.
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 **:
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.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
The style DSL block used to describe the style with runtime styling on top of it.
callback triggered when the style is successfully loaded.
Deprecated
Loading style was revisited in v11, this method is deprecated. IMPORTANT: onMapLoadErrorListener and styleTransitionOptions will not be applied anymore, please refer to documentation for new method to understand how to apply them properly.
Replace with
loadStyle(styleExtension, onStyleLoaded)
Legacy method to load style, please refer to deprecation message for more details.
Deprecated
Loading style was revisited in v11, this method is deprecated. IMPORTANT: onMapLoadErrorListener will not be triggered anymore, please refer to documentation for new method to understand how to handle errors.
Replace with
loadStyle(styleExtension, onStyleLoaded)
Legacy method to load style, please refer to deprecation message for more details.