调整“animateTo”位置

时间:2012-09-28 15:06:45

标签: android android-mapview

我的mapview上显示了一个兴趣点,当点击它时,我会点击animateTo将其置于屏幕中心。但是,我点击后弹出的注释有时太高而被切断屏幕顶部。我想稍微向下移动mapview,这样整个视图就会显示给用户,而不必向下移动。

1 个答案:

答案 0 :(得分:1)

这为您提供当前缩放级别的屏幕中心每个像素的纬度值:

pixelValueY = projection.fromPixels(mapView.getwidth()/2 ,mapView.getHeight()/2).getLatitudeE6() -  projection.fromPixels(mapView.getwidth()/2 ,mapView.getHeight()/2 +1).getLatitudeE6();

现在假设您要移动地图20像素,您只需将上述值添加到原始中心位置的纬度:

mapController.animateTo(new GeoPoint(originalCenterLat + 20 * pixelValueY , originalCenterLon));
祝你好运