rotateAroundPointRaw method
MoveAndRotateResult
rotateAroundPointRaw(
- double degree, {
- required Offset? offset,
- required bool hasGesture,
- required MapEventSource source,
- String? id,
Internal endpoint to rotate around a point that is not in the center of the map.
Implementation
MoveAndRotateResult rotateAroundPointRaw(
double degree, {
required Offset? offset,
required bool hasGesture,
required MapEventSource source,
String? id,
}) {
if (degree == camera.rotation) {
return const (moveSuccess: false, rotateSuccess: false);
}
if (offset == Offset.zero) {
return (
moveSuccess: true,
rotateSuccess: rotateRaw(
degree,
hasGesture: hasGesture,
source: source,
id: id,
),
);
}
final rotationDiff = degree - camera.rotation;
final rotationCenter = camera.projectAtZoom(camera.center) +
offset!.rotate(camera.rotationRad);
return (
moveSuccess: moveRaw(
camera.unprojectAtZoom(
rotationCenter +
(camera.projectAtZoom(camera.center) - rotationCenter)
.rotate(degrees2Radians * rotationDiff),
),
camera.zoom,
hasGesture: hasGesture,
source: source,
id: id,
),
rotateSuccess: rotateRaw(
camera.rotation + rotationDiff,
hasGesture: hasGesture,
source: source,
id: id,
),
);
}