addImageSourceImage method

Future<CommandCompletion> addImageSourceImage(
  1. String sourceId,
  2. List<LatLng> coordinates,
  3. PremultipliedRgba8Image image
)

Adds an image source that shows image.

coordinates are the image's four corners, clockwise from the top left.

See mln_map_add_image_source_image in the C API reference.

Errors:

  • 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> addImageSourceImage(
  String sourceId,
  List<LatLng> coordinates,
  PremultipliedRgba8Image image,
) => _command((arena, completion) {
  final nativecoordinates = arena<raw.mln_lat_lng>(
    coordinates.isEmpty ? 1 : coordinates.length,
  );
  for (var index = 0; index < coordinates.length; index++) {
    _writeLatLng(coordinates[index], arena, into: nativecoordinates + index);
  }
  return raw.mln_map_add_image_source_image(
    _handle.raw,
    nativeStringView(sourceId, arena).value,
    nativecoordinates,
    coordinates.length,
    _writePremultipliedRgba8Image(image, arena),
    completion,
    nativeDiagnostic,
  );
});