如何计算点周围半径在Android图形页面? [英] How to compute a radius around a point in an Android MapView?

查看:177
本文介绍了如何计算点周围半径在Android图形页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个<一个href="http://$c$c.google.com/android/add-ons/google-apis/reference/index.html?com/google/android/maps/MapView.html">MapView我正在显示一个有用半径(想想坐标精度)的,利用图形页面的<一个href="http://$c$c.google.com/android/add-ons/google-apis/reference/com/google/android/maps/Projection.html">Projection's <一href="http://$c$c.google.com/android/add-ons/google-apis/reference/com/google/android/maps/Projection.html#metersToEquatorPixels%28float%29">metersToEquatorPixels,这是无可否认的只是赤道的距离)不给我一个准确的足够的距离(以像素为单位)。你会如何​​计算这个,如果你想显示你的坐标,​​给定的半径绕一大圈?

I have a MapView that I'm displaying a "useful radius" (think accuracy of coordinate) in. Using MapView's Projection's metersToEquatorPixels, which is admittedly just for equatorial distance) isn't giving me an accurate enough distance (in pixels). How would you compute this if you wanted to display a circle around your coordinate, given radius?

推荐答案

所以,谷歌地图使用墨卡托投影。这意味着,进一步从赤道越失真的距离变得得到。根据这个讨论,适当的方式转换的距离是一样的东西:

So, Google Maps uses a Mercator projection. This means that the further you get from the equator the more distorted the distances become. According to this discussion, the proper way to convert for distances is something like:

public static int metersToRadius(float meters, MapView map, double latitude) {
    return (int) (map.getProjection().metersToEquatorPixels(meters) * (1/ Math.cos(Math.toRadians(latitude))));         
}

这篇关于如何计算点周围半径在Android图形页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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