2013-01-04 97 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;  
    } 
} 
相关问题