addGeoJsonSource method

Future<CommandCompletion> addGeoJsonSource(
  1. String sourceId, {
  2. GeoJsonSourceOptions? options,
  3. String? attribution,
})

Adds a GeoJSON source with no data.

Give it data with MapHandle.setGeoJsonSourceData() or MapHandle.setGeoJsonSourceUrl(). Its options stay fixed for as long as the style holds it.

attribution is the source's [attribution](https://maplibre.org/maplibre-style-spec/sources/#attribution), or empty for none.

See mln_map_add_geo_json_source in the C API reference.

Errors:

  • Status.invalidArgument when an option in options is out of range.
  • Status.alreadyExists when the style already has a source named sourceId.
  • Status.invalidState while the style isn't loaded, as MapHandle.setStyleUrl() describes.

Implementation

Future<CommandCompletion> addGeoJsonSource(
  String sourceId, {
  GeoJsonSourceOptions? options,
  String? attribution,
}) => _command(
  (arena, completion) => raw.mln_map_add_geo_json_source(
    _handle.raw,
    nativeStringView(sourceId, arena).value,
    options == null ? nullptr : _writeGeoJsonSourceOptions(options, arena),
    attribution == null
        ? arena<raw.mln_buffer_view>().ref
        : nativeStringView(attribution, arena).value,
    completion,
    nativeDiagnostic,
  ),
);