I have the following way to update my map:
private void setCamera() { if (currentLocation != null) { String[] coords = currentLocation.split(",", 2); CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(Double.parseDouble(coords[0]), Double.parseDouble(coords[1]))); CameraUpdate zoom = CameraUpdateFactory.zoomTo(5); mMap.moveCamera(center); mMap.animateCamera(zoom); } }
The first time I call this method immediately after opening the application, and this method works fine. But after that, I move on to another fragment, and then to the first fragment again. And in this case, the method was called, currentLocation not equal to zero, center received the correct LatLng object, but my map view did not change, and the scale is less than 5. What is wrong?
source share