【发布时间】:2011-12-14 13:06:08
【问题描述】:
我有一个以 P 点为中心的 MapView。用户无法更改 MapView 中心,但他可以选择要在 P 点周围显示的圆的半径,并在每次更改时重新绘制地图时动态更改它显示新圈子。 问题是,我希望地图根据需要放大或缩小,以便在可视区域显示整个圆圈。我试过这个:
Projection proj = m_Map.getProjection();
Point mapCenterPixles = new Point();
proj.toMapPixels(center, mapCenterPixles);
float radiusPixels = proj.metersToEquatorPixels(newRadius);
IGeoPoint topLeft = proj.fromPixels(mapCenterPixles.x - radiusPixels,
mapCenterPixles.y - radiusPixels);
IGeoPoint bottomRight = proj.fromPixels(mapCenterPixles.x
+ radiusPixels, mapCenterPixles.y + radiusPixels);
m_Map.getController().zoomToSpan(
topLeft.getLatitudeE6() - bottomRight.getLatitudeE6(),
topLeft.getLongitudeE6() - bottomRight.getLongitudeE6());
但我似乎遗漏了一些东西,因为传递给 zoomToSpan() 的值不会导致任何变化,我有点迷失在这里,有人可以说明如何缩放地图以跨越边界框以米为单位的圆的半径及其中心点?
【问题讨论】:
标签: android