fitCameraToLatLngBounds method

Future<CommandCompletion> fitCameraToLatLngBounds(
  1. LatLngBounds bounds,
  2. CameraFitUpdate update
)

Moves the camera to fit bounds in the map's view, at once or with an animation.

The camera is the one that MapHandle.cameraForLatLngBounds() computes after the commands sent before this one apply. The function finishes when the map applies the change, before an animation ends.

See mln_map_fit_camera_to_lat_lng_bounds in the C API reference.

Errors:

  • Status.invalidArgument when the padding in update leaves no room for the area. The camera doesn't move.

Implementation

Future<CommandCompletion> fitCameraToLatLngBounds(
  LatLngBounds bounds,
  CameraFitUpdate update,
) => _command((arena, completion) {
  final registrations = _NativeRegistrations(_callbackRoots);
  return registrations.run(
    () => raw.mln_map_fit_camera_to_lat_lng_bounds(
      _handle.raw,
      _writeLatLngBounds(bounds, arena).ref,
      _writeCameraFitUpdate(update, arena, registrations),
      completion,
      nativeDiagnostic,
    ),
  );
});