animatedFitCamera method

Future<void> animatedFitCamera({
  1. required CameraFit cameraFit,
  2. Curve? curve,
  3. String? customId,
  4. double? rotation,
})

Will use the cameraFit to calculate the center and zoom level and then animate to that position.

If curve is not specified, the one specified in the constructor will be used.

Implementation

Future<void> animatedFitCamera({
  required CameraFit cameraFit,
  Curve? curve,
  String? customId,
  double? rotation,
}) {
  MapCamera camera = mapController.camera;
  if (rotation != null) {
    camera = camera.withRotation(rotation);
  }

  final centerZoom = cameraFit.fit(camera);

  return animateTo(
    dest: centerZoom.center,
    zoom: centerZoom.zoom,
    curve: curve,
    customId: customId,
    rotation: rotation,
  );
}