setStyleUrl method

Future<CommandCompletion> setStyleUrl(
  1. String url
)

Loads the map's style from url.

The command completes once the style document has loaded and parsed. The style's sources, sprites, and glyphs then load in the background.

The map's style is loaded from the time a style document parses until the next call to this function. While the style isn't loaded, the commands that change it complete with Status.invalidState. To change a new map's style without a style document, first load an empty style, such as {"version":8,"sources":{},"layers":[]}.

See mln_map_set_style_url in the C API reference.

Errors:

  • Status.nativeError when the style document fails to load or isn't a valid style.
  • Status.cancelled when the map is released, or this function or MapHandle.setStyleJson() loads another style, before the style document parses.

Implementation

Future<CommandCompletion> setStyleUrl(String url) => _command(
  (arena, completion) => raw.mln_map_set_style_url(
    _handle.raw,
    nativeStringView(url, arena).value,
    completion,
    nativeDiagnostic,
  ),
);