Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Latitude/Longitude span in Google Map V2 for Android

I have a task for move my app to Google Maps Android APIs V2. Now, I need to get Latitude/Longitude span. I used MapView.getLatitudeSpan() and MapView.getLongitudeSpan() in previous version APIs. Now I can't find something like this in V2.

Does anybody have the same problem?

like image 322
Rusfearuth Avatar asked Dec 06 '12 07:12

Rusfearuth


1 Answers

You can use the following code to get the lat/lng span:

VisibleRegion vr = mMap.getProjection().getVisibleRegion();
double left = vr.latLngBounds.southwest.longitude;
double top = vr.latLngBounds.northeast.latitude;
double right = vr.latLngBounds.northeast.longitude;
double bottom = vr.latLngBounds.southwest.latitude;

I hope this helps.

like image 69
Paul Wein Avatar answered Oct 14 '22 15:10

Paul Wein