Style

Style provides access to the APIs used to dynamically modify the map’s style. Use it to read and write layers, sources, and images. Obtain the Style instance for a MapView via MapView.mapboxMap.style.

Important

Style should only be used from the main thread.
  • Adds a source to the map

    Throws

    StyleError if there is a problem adding the source.

  • Retrieves a source from the map

    Throws

    StyleError if there is a problem getting the source data.

    Throws

    TypeConversionError if there is a problem decoding the source data to the given type.

  • Retrieves a source from the map

    This function is useful if you do not know the concrete type of the source you are fetching, or don’t need to know for your situation.

    Throws

    StyleError if there is a problem getting the source data.

    Throws

    TypeConversionError if there is a problem decoding the source of given id.
  • Updates the data property of a given GeoJSONSource with a new value conforming to the GeoJSONObject protocol.

    Throws

    StyleError if there is a problem when updating GeoJSON source.

    Attention

    This method is only effective with sources of GeoJSONSource type, and cannot be used to update other source types.

  • true if and only if the style JSON contents, the style specified sprite, and sources are all loaded, otherwise returns false.

  • uri

    Get or set the style URI

    Setting a new style is asynchronous. In order to get the result of this operation, listen to MapEvents.styleDataLoaded, MapEvents.styleLoaded.

    Attention

    This method should be called on the same thread where the MapboxMap object is initialized.
  • Get or set the style via a JSON serialization string

    Attention

    This method should be called on the same thread where the MapboxMap object is initialized.
  • 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. Values default to 0.0 if they are not defined in the style.

  • Get or set the map style‘s transition options.

    By default, the style parser will attempt to read the style default transition, if any, falling back to a 0.3 s transition otherwise.

    Overridden transitions are reset once a new style has been loaded. To customize the transition used when switching styles, set this property after MapEvents.EventKind.styleDataLoaded where Event.type == "style" and before MapEvents.EventKind.styleDataLoaded where Event.type == "sprite" and where Event.type == "sources".

    See also

    MapboxMap/onNext(_:handler:)