PolyWidget.threePoints constructor
PolyWidget.threePoints({
- required LatLng pointA,
- required LatLng pointB,
- required LatLng approxPointC,
- required Widget child,
- Orientation? forceOrientation,
- bool? noRotation,
poly widget defined by three points
should always be added inside PolyWidgetLayer.polyWidgets
pointA
and pointB
are fixed and will be used to define the width and angle of your widget. approxPointC
is only fixed
Implementation
// if it is placed in a 90° angle from [pointB]. Otherwise the distance from [pointB] to [approxPointC] is used to calculate the actual third corner. All three corners are used to calculate
// the center location.
factory PolyWidget.threePoints({
required LatLng pointA,
required LatLng pointB,
required LatLng approxPointC,
required Widget child,
Orientation? forceOrientation,
bool? noRotation,
}) {
double width = const Distance().distance(pointA, pointB);
double height = const Distance().distance(pointB, approxPointC);
double xAngle = const Distance().bearing(pointA, pointB);
LatLng centerLine = const Distance().offset(pointA, width / 2, xAngle);
double yAngle = const Distance().bearing(pointB, approxPointC);
double cDirection = ((yAngle - xAngle) % 360);
double cDirectionAngle = cDirection >= 0 && cDirection < 180 ? 90 : -90;
LatLng center = const Distance()
.offset(centerLine, height / 2, xAngle + cDirectionAngle);
return PolyWidget(
center: center,
widthInMeters: width.toInt(),
heightInMeters: height.toInt(),
angle: xAngle - 90,
forceOrientation: forceOrientation,
noRotation: noRotation,
child: child,
);
}