Reputation: 30276
I'm using Google Map API to show all locations in database. When user scrolls to one point in map, every visible area on map should be checked and return all locations in my database.
Because user can zoom in / zoom out in map, so minimum and maximum coordinate can view on map is vary base on scaling (and maybe phone screen size, too). So my question is, does android google map sdk supports function, so I can called to get minimum/maximum coordinate (in latitude, longitude) can be showed on map.
Thanks :)
Upvotes: 1
Views: 1662
Reputation: 5563
I think you can use this code for determining map's bounds
GoogleMap map;
map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
//those are corners of visible region
VisibleRegion visibleRegion = map.getProjection().getVisibleRegion();
LatLng farLeft = visibleRegion.farLeft;
LatLng farRight = visibleRegion.farRight;
LatLng nearLeft = visibleRegion.nearLeft;
LatLng nearRight = visibleRegion.nearRight;
}
});
Upvotes: 5