2012-09-28 37 views
0

我的興趣點顯示在我的mapview上,點擊時,我觸發animateTo將其居中在屏幕上。但是,點擊後彈出的註釋有時候太高,並且會從屏幕頂部切掉。我想稍微向下移動mapview,這樣整個視圖就會顯示給用戶,而不必再向下移動。調整「animateTo」位置

回答

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)); 

好運

+0

你是我心目中的英雄的人。謝謝! – RyanInBinary

+0

不客氣。 – Luis