GroundOverlay在谷歌地图Android的API V2一个帆布制成 [英] GroundOverlay made with a Canvas in Google Maps Android API v2

查看:240
本文介绍了GroundOverlay在谷歌地图Android的API V2一个帆布制成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也试着画弧(我引用的<一个href="http://stackoverflow.com/questions/16143122/application-crashes-displaying-a-groundoverlay-made-with-a-canvas-in-google-maps">this和<一href="http://stackoverflow.com/questions/20382823/google-maps-api-v2-draw-part-of-circle-on-mapfragment">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;
}

这篇关于GroundOverlay在谷歌地图Android的API V2一个帆布制成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆