我有以下更新地图的方法:
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);
}
}
当我第一次打开应用程序并立即调用此方法时,该方法可以正常工作。但是之后我转到另一个片段,然后再次回到第一个片段。在这种情况下,该方法被调用,currentLocation
不等于 null,center
得到了正确的 LatLng
对象,但我的地图视图没有改变,缩放小于 5。出了什么问题?