2013-01-04 93 views
0

我在找經緯度值右上角的地圖查看使用android googel maps V2。我在同一個問題上發佈了類似的問題,但沒有用。如何在使用android谷歌地圖V2獲取地圖經度和緯度

我爲此編寫了代碼,但獲得了零值。

請檢查我的代碼:

MapView mapView = ((SupportMapFragment) getSupportFragmentManager() 
        .findFragmentById(R.id.map)).getMap(); 

    LatLngBounds bounds = mapView.getProjection().getVisibleRegion().latLngBounds; 
      LatLng topright = bounds.northeast; 
      double toprgt_latitude = topright.latitude; 

      Log.d("top lat", "" + toprgt_latitude);//getting zero values. 

在此先感謝。

回答

0
LatLng currentposition = new LatLng(location.getLatitude(), location.getLongitude()); 
sys.out.println(""+location.getLatitude()""+location.getLongitude()); 
1

在地圖顯示後使用mapView.getProjection()。getVisibleRegion()。latLngBounds.northeast。

LatLng corner; 

mapView.setOnCameraChangeListener(new OnCameraChangeListener() { 
    @Override 
    public void onCameraChange(CameraPosition position) { 
    corner = mapView.getProjection().getVisibleRegion().latLngBounds.northeast;  
    } 
} 
相關問題