toList method
Create a list of all the LatLng
s along the outline of this region
Not supported on line regions: use toOutlines()
instead.
Returns a List<LatLng>
which can be used anywhere.
Implementation
@override
List<LatLng> toList() {
final double rad = radius / 1.852 / 3437.670013352;
final double lat = center.latitudeInRad;
final double lon = center.longitudeInRad;
final List<LatLng> output = [];
for (int x = 0; x <= 360; x++) {
final double brng = x * math.pi / 180;
final double latRadians = math.asin(
math.sin(lat) * math.cos(rad) +
math.cos(lat) * math.sin(rad) * math.cos(brng),
);
final double lngRadians = lon +
math.atan2(
math.sin(brng) * math.sin(rad) * math.cos(lat),
math.cos(rad) - math.sin(lat) * math.sin(latRadians),
);
output.add(
LatLng(
latRadians * 180 / math.pi,
(lngRadians * 180 / math.pi)
.clamp(-180, 180), // Clamped to fix errors with flutter_map
),
);
}
return output;
}