center property
Point
get
center
Gets the center Point of the FeatureCollection. This is an average of all the Points that create the Features in the FeatureCollection.
Example:
FeatureCollection([
Point(Coordinate(1, 2)),
Point(Coordinate(5, 6))
]).center; // Point(4, 5)
Implementation
Point get center {
List<Point> points = (explode().features as List<Point>);
double lat = 0;
double long = 0;
for (final point in points) {
lat += point.coordinate.latitude;
long += point.coordinate.longitude;
}
return Point.fromLatLong(lat / points.length, long / points.length);
}