zme*_*eda 6 android overlay projection android-mapview
我的已知数据是我当前的位置(GeoPoint)和以米为单位的半径.我想根据地图投影和半径在当前位置周围绘制圆圈.我的地图视图叠加确实覆盖了绘制方法
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Projection projection = mapView.getProjection();
GeoPoint myLocationGeoPoint = getLocationGeoPointFromSomeSource();
Point myPoint = new Point();
projection.toPixels(myLocationGeoPoint, myPoint);
int radiusPixel = (int) projection.metersToEquatorPixels(getRadiusInMetersFromSomeSource());
canvas.drawCircle(myPoint.x, myPoint.y, radiusPixel, mPaintStroke);
canvas.drawCircle(myPoint.x, myPoint.y, radiusPixel, mPaintFill);
super.draw(canvas, mapView, shadow);
}
Run Code Online (Sandbox Code Playgroud)
这段代码的问题radiusPixel太小了.我假设问题出在metersToEquatorPixels以米为参数并计算大约的方法中.像素是否在赤道上.我对吗?但我想计算一下,如果我站在赤道上,我的半径需要多少像素.这种工作是否有内置功能,还是我必须手工完成?
问候
| 归档时间: |
|
| 查看次数: |
5174 次 |
| 最近记录: |