我有一个地图视图,其中显示了“有用半径”(类似于坐标的准确性)。使用 MapView
的投影 的metersToEquatorPixels(仅适用于赤道距离)并不能给出足够准确的距离(以像素为单位)。如果您想在坐标周围显示圆圈,该如何计算半径?
我有一个地图视图,其中显示了“有用半径”(类似于坐标的准确性)。使用 MapView
的投影 的metersToEquatorPixels(仅适用于赤道距离)并不能给出足够准确的距离(以像素为单位)。如果您想在坐标周围显示圆圈,该如何计算半径?
所以,谷歌地图使用Mercator投影。这意味着你离赤道越远,距离就越扭曲。根据这个讨论,正确的距离转换方法大概是这样的:
public static int metersToRadius(float meters, MapView map, double latitude) {
return (int) (map.getProjection().metersToEquatorPixels(meters) * (1/ Math.cos(Math.toRadians(latitude))));
}
mMap.addCircle(
new CircleOptions().center(
new LatLng(
bounds.getCenter().latitude,
bounds.getCenter().longitude
)
)
.radius(50000)
.strokeWidth(0f)
.fillColor(0x550000FF)
);
projection.toPixels(GeoP, pt);
float radius = projection.metersToEquatorPixels(50);
试试这个...我在我的MapRadius上使用它,看起来是有效的