我試圖獲取地圖中心的經緯度,在Google Maps V2 API &中獲取寬度和長度地圖。Android GMaps v2 - 獲取地圖中心的位置和地圖的高度和寬度
這裏是我的舊代碼(從GMaps V1,我開始修改):
import com.google.android.gms.maps.GoogleMap;
private GoogleMap mGoogleMapView;
public LatLng getMapCenter()
{
if(mGoogleMapView != null)
{
return mGoogleMapView.getMapCenter();
}
/*if(mOpenStreetMapView != null)
{
return convertOSMGeoPoint(mOpenStreetMapView.getMapCenter());
}*/
return null;
}
public int getHeight()
{
if(mGoogleMapView != null)
{
return mGoogleMapView.getHeight();
}
/*if(mOpenStreetMapView != null)
{
return mOpenStreetMapView.getHeight();
}*/
return 0;
}
public int getWidth()
{
if(mGoogleMapView != null)
{
return mGoogleMapView.getWidth();
}
/*else if(mOpenStreetMapView != null)
{
return mOpenStreetMapView.getWidth();
}*/
return 0;
}
我怎麼能執行相同的功能,mapView.getMapCenter(),mapView.getHeight(),和MapView的。 getWidth()使用Android GMaps V2 API?
如果你能提供一個很好的例子。 – user268397 2013-05-03 01:10:55
請檢查我對答案的編輯。 – zbr 2013-05-03 01:33:46