2013-10-13 44 views
1

我在網上看過,但找不到準確的答案。我有一個ImageView用作以地圖爲中心的標記,當我平移地圖時,它的位置不會改變。當我停止在地圖上平移時,我想獲得位置的位置。我想我必須使用投影,但由於我不是那麼專業的機器人我卡住了。任何人都可以幫忙嗎?android如何將像素座標轉換爲Latvng上的mapsv2

+0

你試過直接使用標記嗎? – 2015-10-17 15:02:59

回答

1

使用Projection通過map.getProjection()

這將允許您在屏幕座標和LatLng之間進行轉換。返回的像素是相對於包含地圖的View

+0

我需要在哪裏調用此方法? onCreate還是其他地方? – regeme

+0

每當你想要。地圖需要設置。 'onCreate'是合理的。 –

0

對於地圖API V2

VisibleRegion vr = mMap.getProjection().getVisibleRegion(); 
double left = vr.latLngBounds.southwest.longitude; 
double top = vr.latLngBounds.northeast.latitude; 
double right = vr.latLngBounds.northeast.longitude; 
double bottom = vr.latLngBounds.southwest.latitude; 

您也可以使用,

LatLngBounds curScreen = mMap.getProjection() 
       .getVisibleRegion().latLngBounds; 

希望這會有所幫助。

5

使用map.getProjection()。fromScreenLocation(點)map.getProjection()。toScreenLocation(經緯度)到屏幕的位置和地理位置之間的轉換。

相關問題