Android中Google Map V2上圆圈上的LatLng点

Android中Google Map V2上圆圈上的LatLng点,android,google-maps,Android,Google Maps,我需要存储谷歌地图上画的所有圆圈的点。比如: 我有圆和半径(米)。怎么弄到的?。我试着用代码 private ArrayList<LatLng> makeCircle(LatLng centre, double radius, float zoom) { ArrayList<LatLng> points = new ArrayList<LatLng>(); LatLngBounds.Builder builder = new LatL

我需要存储谷歌地图上画的所有圆圈的点。比如:

我有圆和半径(米)。怎么弄到的?。我试着用代码

 private ArrayList<LatLng> makeCircle(LatLng centre, double radius, float zoom)
 {
     ArrayList<LatLng> points = new ArrayList<LatLng>();
     LatLngBounds.Builder builder = new LatLngBounds.Builder();
      
     double EARTH_RADIUS = 6378100.0;

     for (double t = 0; t <= Math.PI * 2; t += 1.0)
     {
         double rad = radius + zoom * EARTH_RADIUS;
         double latPoint = centre.latitude + (rad / EARTH_RADIUS) * Math.sin(t);
         double lonPoint = centre.longitude + (rad / EARTH_RADIUS) * Math.cos(t) / Math.cos(centre.latitude);
         points.add(new LatLng(latPoint * 180.0 / Math.PI, lonPoint * 180.0 / Math.PI));
         Marker customMarker = map.addMarker(new MarkerOptions()
        .position(new LatLng(latPoint,lonPoint)));
        
         builder.include(new LatLng(latPoint,lonPoint));
        
         LatLngBounds bound = builder.build();
         CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bound, width-100, height-100, 20);
         map.animateCamera(cu);
     }
     return points;
 }
private ArrayList makeCircle(车床中心、双半径、浮动缩放)
{
ArrayList points=新的ArrayList();
LatLngBounds.Builder=新的LatLngBounds.Builder();
双接地半径=6378100.0;

对于(double t=0;t,“缩放”因子与此处的计算无关。请按如下所示更新makeCircle()方法,它将完全按照您想要的方式工作:

private ArrayList<LatLng> makeCircle(LatLng centre, double radius) 
    { 
    ArrayList<LatLng> points = new ArrayList<LatLng>(); 

    double EARTH_RADIUS = 6378100.0; 
    // Convert to radians. 
    double lat = centre.latitude * Math.PI / 180.0; 
    double lon = centre.longitude * Math.PI / 180.0; 

    for (double t = 0; t <= Math.PI * 2; t += 0.3) 
    { 
    // y 
    double latPoint = lat + (radius / EARTH_RADIUS) * Math.sin(t); 
    // x 
    double lonPoint = lon + (radius / EARTH_RADIUS) * Math.cos(t) / Math.cos(lat);

    // saving the location on circle as a LatLng point
    LatLng point =new LatLng(latPoint * 180.0 / Math.PI, lonPoint * 180.0 / Math.PI);

    // here mMap is my GoogleMap object 
    mMap.addMarker(new MarkerOptions().position(point));

    // now here note that same point(lat/lng) is used for marker as well as saved in the ArrayList 
    points.add(point);

    } 

    return points; 
    }
private ArrayList makeCircle(板条中心,双半径)
{ 
ArrayList points=新的ArrayList();
双接地半径=6378100.0;
//转换成弧度。
双纬度=中心纬度*Math.PI/180.0;
双经度=中心经度*Math.PI/180.0;

对于(双t=0;t不确定是否有用。请检查此项。不,不起作用。我不知道哪里有计算错误。根据我的想法,如果在制作圆时将获得准确的缩放级别,则可以解决此问题。因此,在计算标记显示在正确的位置后,或者您无法使用它们绘制圆。不,它显示不同的圆作为d在图上用红色记号笔画的。但我想要那个用黑色圆圈标记的圆圈,这意味着你们的圆圈里不包括记号笔。