setGeoJsonSourceData method

Future<CommandCompletion> setGeoJsonSourceData(
  1. String sourceId,
  2. Object? data
)

Replaces the data of a GeoJSON source.

data is a GeoJSON feature collection, feature, or geometry. The library prepares it for the source with the source's options, off the threads that the caller and the runtime use, and the command completes once the source holds it. Later commands don't wait for it. While the source is still preparing earlier data, only the newest data waits to follow it.

With synchronous tiling on, as MapHandle.setGeoJsonSourceSynchronousTiling() describes, the command prepares data before later commands run, so the data shows in the next frame.

See mln_map_set_geo_json_source_data in the C API reference.

Errors:

  • Status.notFound when the style has no source named sourceId.
  • Status.invalidArgument when the source named sourceId isn't a GeoJSON source, when data isn't valid GeoJSON, or when the source clusters and data isn't a feature collection of points. The source keeps its data.
  • Status.cancelled when newer data for the source replaces data while it waits, or when the source's URL, its removal, a style load, or the map's release replaces the source's data before data is ready.
  • Status.invalidState while the style isn't loaded, as MapHandle.setStyleUrl() describes.

Implementation

Future<CommandCompletion> setGeoJsonSourceData(
  String sourceId,
  Object? data,
) => _command(
  (arena, completion) => raw.mln_map_set_geo_json_source_data(
    _handle.raw,
    nativeStringView(sourceId, arena).value,
    _nativeJsonView(data, arena),
    completion,
    nativeDiagnostic,
  ),
);