【发布时间】:2016-09-14 11:52:52
【问题描述】:
我有一个问题,当我尝试获取地图的中心时,它与屏幕的中心不同,并且在不同的设备中存在不同的距离差异。我怎样才能获得地图的真正中心?我需要在其中添加一个标记
谢谢
部分 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;
}
【问题讨论】:
-
可以发截图吗?
标签: java android google-maps maps