moveCamera method

  1. @override
void moveCamera(
  1. LatLng location,
  2. double? zoom
)
override

Moves the camera to location, keeping the current zoom when zoom is null.

Attribution applies as it does to fitBounds.

Implementation

@override
void moveCamera(LatLng location, double? zoom) async {
  // One read of the completer: [attach] can swap it mid-call when the
  // platform view is recreated, and reading twice would apply the camera to
  // a different map than the zoom was read from.
  final map = await controller;
  CameraState? cameraState = await map.getCameraState();
  double currentZoom = zoom ?? cameraState.zoom;
  final cameraOptions = CameraOptions(
    center: getPoint(location),
    zoom: currentZoom,
    padding: MbxEdgeInsets(
      top: padding.top,
      bottom: padding.bottom,
      left: padding.left,
      right: padding.right,
    ),
  );

  // Claimed immediately before the camera call: waiting on the map and its
  // camera state is not time the camera is moving, and it would eat the
  // window that ends up attributing this move.
  beginProgrammaticMove();
  map.setCamera(cameraOptions);
}