How to get number of pixels equals to a radius of Geozone circle according to zoom level? OR Radius of zone circle to screen pixels?

亡梦爱人 提交于 2019-12-01 12:23:28
cgr

Credits to and thanks a ton to Android Maps API v2 draw circle post.

I could calculate the width of circle in pixels given latitude, longitude and radius (from given lat, long) in meters.

private int convertZoneRadiusToPixels(double lat, double lng, double radiusInMeters) {
    double EARTH_RADIUS = 6378100.0;
    double lat1 = radiusInMeters / EARTH_RADIUS;
    double lng1 = radiusInMeters / (EARTH_RADIUS * Math.cos((Math.PI * lat / 180)));

    double lat2 = lat + lat1 * 180 / Math.PI;
    double lng2 = lng + lng1 * 180 / Math.PI;

    Point p1 = mMap.getProjection().toScreenLocation(new LatLng(lat, lng));
    Point p2 = mMap.getProjection().toScreenLocation(new LatLng(lat2, lng2));
    return Math.abs(p1.x - p2.x);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!