0

I am looking for latitude and longitude values of top right corner of mapView using Android google maps V2. I posted similar question on the same issue, but no use.

I wrote code for this,but getting zero values.

please check my code:

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.
Cœur
  • 37,241
  • 25
  • 195
  • 267
user1415135
  • 51
  • 1
  • 6

2 Answers2

1

Use mapView.getProjection().getVisibleRegion().latLngBounds.northeast after map is shown.

LatLng corner;

mapView.setOnCameraChangeListener(new OnCameraChangeListener() {
  @Override
  public void onCameraChange(CameraPosition position) {
    corner = mapView.getProjection().getVisibleRegion().latLngBounds.northeast;    
  }
}
TlmaK0
  • 3,578
  • 2
  • 31
  • 51
0
LatLng currentposition = new LatLng(location.getLatitude(), location.getLongitude());
sys.out.println(""+location.getLatitude()""+location.getLongitude());
Pang
  • 9,564
  • 146
  • 81
  • 122
Sushant Patekar
  • 421
  • 1
  • 5
  • 17