rotateAroundPointRaw method
MoveAndRotateResult
rotateAroundPointRaw(})
Internal endpoint to rotate around a point that is not in the center of the map.
Implementation
MoveAndRotateResult rotateAroundPointRaw(
double degree, {
required Point<double>? point,
required Offset? offset,
required bool hasGesture,
required MapEventSource source,
String? id,
}) {
if (point != null && offset != null) {
throw ArgumentError('Only one of `point` or `offset` may be non-null');
}
if (point == null && offset == null) {
throw ArgumentError('One of `point` or `offset` must be non-null');
}
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.project(camera.center) +
(point != null
? (point - (camera.nonRotatedSize / 2.0))
: Point(offset!.dx, offset.dy))
.rotate(camera.rotationRad);
return (
moveSuccess: moveRaw(
camera.unproject(
rotationCenter +
(camera.project(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,
),
);
}