There is an error with animateCamera and LatLngBounds. The method does not move the camera exactly to the expected area. How do I know that? I confirmed that by adding the following code:
private LatLngBounds mBoundingBox; private boolean mCameraAnimated; public void setCurrentLocation(Location currentLocation, String radius, boolean animate) { mCurrLocation = currentLocation; mCurrRadius = MapUtils.getRadiusDecimalValue(radius); mBoundingBox = MapUtils.getBoundingBox(mCurrLocation.getLatitude(), mCurrLocation.getLongitude(), mCurrRadius); mCameraAnimated = animate; if (animate) { mEventMap.animateCamera(CameraUpdateFactory.newLatLngBounds(mBoundingBox, 0)); } else { mEventMap.moveCamera(CameraUpdateFactory.newLatLngBounds(mBoundingBox, 0)); } } @Override public void onCameraChange(CameraPosition cameraPosition) {
Now, after an extra moveCamera, the camera is positioning correctly.
The new problem is that onCameraChange sometimes fails to run this extra moveCamera, and therefore im doesn't execute my actual onCameraChange code (marked as "...").
source share