GroundOverlay在谷歌地图Android的API V2一个帆布制成帆布、地图、GroundOverlay、Android

2023-09-05 01:06:09 作者:心碎了` 有的换么 -

我也试着画弧(我引用的this和this问题)。我会从Web服务得到如下:

I'm also try to draw arc (I'm referencing on this and this questions). I'll get from web service following:

纬度和液化天然气 半径(以米为单位) 在起始角(终止角为启动市场+ 60度)

现在我遇到的以下问题,因为我没有有两个经纬度,只有一个,而在新的地图API V2没有半径= Projection.metersToEquatorPixels方法提供给RectF.set(point.x - 半径,.. 。)

Now I encounter on following problem because I do not have two LatLng, just one, and in new map api v2 there is no radius = Projection.metersToEquatorPixels method for providing to RectF.set(point.x - radius,...)

你有code例如,链接等?

Do you have code example, links, etc?

还有什么关于应用程序的性能,因为我将有多达500个弧在地图上?

Also what about performances of App, because I'll have up to 500 arcs on map?

推荐答案

从经纬度点就可以计算出另一个经纬度点在一个给定的距离(半径)和给定的角度出发,如下所示:

Starting from a LatLng point you can calculate another LatLng point in a given distance (radius) and a given angle as follows:

private static final double EARTHRADIUS = 6366198;

/**
 * Move a LatLng-Point into a given distance and a given angle (0-360,
 * 0=North).
 */
public static LatLng moveByDistance(LatLng startGp, double distance,
        double angle) {
    /*
     * Calculate the part going to north and the part going to east.
     */
    double arc = Math.toRadians(angle);
    double toNorth = distance * Math.cos(arc);
    double toEast = distance * Math.sin(arc);
    double lonDiff = meterToLongitude(toEast, startGp.latitude);
    double latDiff = meterToLatitude(toNorth);
    return new LatLng(startGp.latitude + latDiff, startGp.longitude
            + lonDiff);
}

private static double meterToLongitude(double meterToEast, double latitude) {
    double latArc = Math.toRadians(latitude);
    double radius = Math.cos(latArc) * EARTHRADIUS;
    double rad = meterToEast / radius;
    double degrees = Math.toDegrees(rad);
    return degrees;
}

private static double meterToLatitude(double meterToNorth) {
    double rad = meterToNorth / EARTHRADIUS;
    double degrees = Math.toDegrees(rad);
    return degrees;
}