I have a MapFragment in my Android app and now I would like to know the min and max lat/long that is shown on the map actual.
I found this solution:
If you want to find out the longitude latitude of the corners of the MapView you could use:
Point mapCenter = mapView.getMapCenter();
int latitudeSpan = mapView.getLatitudeSpan() / 2;
int longitudeSpan = mapView.getLongitudeSpan() / 2;
int topLeftLat = mapCenter.getLatitudeE6() + (latitudeSpan);
int topLeftLon = mapCenter.getLongitudeE6() - (longitudeSpan);
int bottomLeftLat = mapCenter.getLatitudeE6() - (latitudeSpan);
int bottomLeftLon = mapCenter.getLongitudeE6() + (longitudeSpan);
My problem now is that I dont have a MapView,
I only have a GoogleMap (com.google.android.gms.maps.GoogleMap) and a MapFragment (com.google.android.gms.maps.MapFragment) .
I need the min/max coordinates to do a DB query for selecting POI-DB-Entrys.
You can get it from your
GoogleMapusinggetVisibleRegionfromProjection.Assuming you named your
GoogleMapasmap, you doVisibleRegionis not necessarily a rectangle, but gives you the bounds, see the docs for more info.