cameraForLatLngs method

Future<CameraOptions> cameraForLatLngs(
  1. List<LatLng> coordinates, {
  2. CameraFitOptions? fitOptions,
})

Computes a camera that fits coordinates in the map's view.

coordinates must not be empty. The camera keeps the map's bearing and pitch unless fitOptions sets them, and its zoom stays within the map's zoom limits.

See mln_map_camera_for_lat_lngs in the C API reference.

Errors:

  • Status.invalidArgument when the padding in fitOptions leaves no room for the area.

Implementation

Future<CameraOptions> cameraForLatLngs(
  List<LatLng> coordinates, {
  CameraFitOptions? fitOptions,
}) => _query(_resultCameraOptions, (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_camera_for_lat_lngs(
    _handle.raw,
    nativecoordinates,
    coordinates.length,
    fitOptions == null ? nullptr : _writeCameraFitOptions(fitOptions, arena),
    completion,
    nativeDiagnostic,
  );
});