getCirclePoints static method
获取一串正圆坐标,可以利用多边形绘制圆
Implementation
//@radiusMi:半径(米)
static List<LatLng> getCirclePoints({required LatLng center, required double radiusMi,int pointLen = 10}) {
List<LatLng> points = [];//此参数用于存储多边形的经纬度,
//地球周长
double perimeter = 2*Math.pi*6371000;
//纬度latitude的地球周长:latitude
double perimeterLatitude = perimeter*Math.cos(Math.pi * center.latitude / 180);
//一米对应的经度(东西方向)1M实际度
double lngRate = 360 / perimeterLatitude;
double latRate = 360 / perimeter;
//10度转角度
double phase = (2 * Math.pi/360) * pointLen;
for (int i = 0; i <= 360/pointLen; i++) {
points.add(new LatLng(
center.latitude + Math.sin(phase*i)*latRate* radiusMi ,
center.longitude - Math.cos(phase*i)*lngRate* radiusMi
));
}
return points;
}