0

假设我有一个点,比如 lat:41.01522 和 lon:28.95221。我需要计算 X latx 和 lonx 以便这些点在给定半径的该点周围创建一个圆(均匀分布)。

知道怎么做吗?

4

2 回答 2

1

这就是我的做法:

@Override
public void draw(Canvas canvas, MapView mapview, boolean shadow) {
    super.draw(canvas, mapview, shadow);

        if(location != null){
            //---translate the GeoPoint with center to screen pixels---
            screenPts = new Point();
            mapview.getProjection().toPixels(new GeoPoint((int)(location.getLatitude()*1E6),(int)(location.getLongitude()*1E6)) , screenPts);


            //Draw accuracy marker
            GeoPoint g0 = mapview.getProjection().fromPixels(0, screenPts.y);
            GeoPoint g1 = mapview.getProjection().fromPixels(width, screenPts.y);
            l0.setLatitude(g0.getLatitudeE6()/1E6);
            l0.setLongitude(g0.getLongitudeE6()/1E6);
            l1.setLatitude(g1.getLatitudeE6()/1E6);
            l1.setLongitude(g1.getLongitudeE6()/1E6);
            float d01=l0.distanceTo(l1);
            int size=(int)(location.getAccuracy() * width / d01);
            canvas.drawCircle(screenPts.x, screenPts.y, size, paintAccuracyFill);
            canvas.drawCircle(screenPts.x, screenPts.y, size, paintAccuracyStroke);
        }
}

祝你好运,路易斯

于 2012-07-19T02:41:26.720 回答
0

好吧,几个小时后,我想我已经足够关闭了:

            double lat3, lon3;
            int n = 15;
            double radius = 0.0006;
            for (double i = 0; i < 360; i += 360 / n) {

                double cos1 = radius * Math.cos(Math.toRadians(i));
                double sin1 = radius * Math.sin(Math.toRadians(i));
                lat3 = lat + (sin1);
                lon3 = lon + (cos1);
                Log.i("change", String.valueOf(i) + ":" + String.valueOf(cos1)
                        + "," + String.valueOf(sin1));
                items.add(new OverlayItem(getPoint(lat3, lon3), String
                        .valueOf(i), "snippet"));
            } 

如果你想在中心的一个对象周围插入覆盖层,我猜你就是这样做的......

于 2012-07-17T12:22:38.993 回答