Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 贴图v2将距离转换为像素_Android - Fatal编程技术网

Android 贴图v2将距离转换为像素

Android 贴图v2将距离转换为像素,android,Android,我一直在找,但找不到。我正在使用谷歌地图v2。有没有办法把屏幕上的距离(米)转换成像素?我需要相当于距离的像素。我有距离和缩放级别。 非常感谢您的帮助。如果我理解正确,您的屏幕上有一个显示地图的地图片段。您知道屏幕上显示的地图上两个点之间的距离(以米为单位),并希望计算这两个点之间的距离(以像素为单位)。如果知道两点的LatLng位置,可以使用如下投影类: Point point1 = map.getProjection().toScreenLocation(latLng1); Point po

我一直在找,但找不到。我正在使用谷歌地图v2。有没有办法把屏幕上的距离(米)转换成像素?我需要相当于距离的像素。我有距离和缩放级别。
非常感谢您的帮助。

如果我理解正确,您的屏幕上有一个显示地图的地图片段。您知道屏幕上显示的地图上两个点之间的距离(以米为单位),并希望计算这两个点之间的距离(以像素为单位)。如果知道两点的LatLng位置,可以使用如下投影类:

Point point1 = map.getProjection().toScreenLocation(latLng1);
Point point2 = map.getProjection().toScreenLocation(latLng2);

然后你只需要使用距离的数学公式:

你能澄清一下你是在转换两点的距离吗?或者你想知道你的屏幕显示了多少英里?距离在2点之间。但是我只知道距离,不知道点。实际上,我有一个圆圈(所以我知道圆心和半径。我想知道这个半径等于多少像素。谢谢你的回答。但是我不知道两点的间距。我只知道以米为单位的距离和一点。例如,想象一个圆心和半径的圆。我想知道这个半径等于多少像素。+1谢谢或者,对于那些感到懒惰的人来说,答案是:)这是方程式Math.sqrt((Math.pow(point2.x-point1.x,2)+Math.pow(point2.y-point1.y,2));