我有一個問題,當我嘗試獲取地圖的中心時,它與屏幕的中心不同,並且在不同的設備中存在不同的距離差異。我如何獲得地圖的真正中心?我需要在裏面添加標記谷歌地圖,得到中心不在中心。 Android
感謝您的XML代碼的
部分:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map" tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="@+id/crosshair"
android:src="@drawable/crosshair"
android:onClick="btPontoClick"
android:layout_centerInParent="true"/>
</RelativeLayout>
的Java代碼,獲得中心:
public void btPontoClick(View v){
LatLng latlng = mMap.getCameraPosition().target;
addPonto(latlng);
okParaVoltar = false;
}
你能發表截圖嗎? – antonio