fitBounds method
Moves the camera to fit points.
Implementations whose provider reports no reason for a camera change
should mix in MapMoveAttribution and call beginProgrammaticMove()
immediately before the platform call, so the move it produces is not
reported to the host as a user gesture. See MapMoveSource.
Implementation
@override
Future<void> fitBounds(List<LatLng> points) async {
final List<Point> mapboxPoints = getPoints(points);
if (mapboxPoints.length < 2) {
return;
}
// One read of the completer, for the reason [moveCamera] gives: [attach]
// can swap it mid-call when the platform view is recreated, and the camera
// computed for one map would then be applied to another.
final map = await controller;
final coordinates = await map.cameraForCoordinatesPadding(
mapboxPoints,
CameraOptions(
padding: MbxEdgeInsets(
top: padding.top,
left: padding.left,
bottom: padding.bottom,
right: padding.right,
),
),
null,
13,
null,
);
beginProgrammaticMove();
map.setCamera(coordinates);
}