setCamera method
Puts the camera at camera: its centre, and also which way it faces
and how far it leans.
With a duration the camera travels there over that time; called once
a second with a one-second duration it follows a moving position without
a jump between fixes. With none it uses the provider's own animation,
and with Duration.zero it is there at once.
Attribution applies as it does to fitBounds, so a host that follows a position can tell its own steps from the user taking the map over.
Implementation
@override
void setCamera(MapViewCamera camera, {Duration? duration}) async {
await _withMap((map) async {
final update = CameraUpdate.newCameraPosition(
CameraPosition(
target: camera.center.toGoogleMapLatLng(),
zoom: camera.zoom ?? await map.getZoomLevel(),
bearing: camera.bearing,
tilt: camera.tilt,
),
);
// After the zoom has been read, for the reason [fitBounds] gives.
beginProgrammaticMove();
if (duration == Duration.zero) {
await map.moveCamera(update);
} else {
await map.animateCamera(update, duration: duration);
}
});
}