Is there a simple way to get the LatLngBounds
of the visible map from a CameraPosition
with Android Google Maps API v2 so that I can use the OnCameraChangeListener
to go fetch new data for the markers.
mMap.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { LatLngBounds bounds = ?; fetchNewData(bounds); } });
An immutable class representing a latitude/longitude aligned rectangle.
Go to APIs & Services → Dashboard → Enable APIs & Services at the top and Choose Maps Javascript API from the API Library. This will open up the Map JavaScript API page, and Enable it.
You can't get the LatLngBounds from the CameraPosition, but you can get them easily from the GoogleMap.
private GoogleMap mMap; mMap.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds; fetchData(bounds); } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With