I need to move Camera to cover all Markers on it. So, I build LatLngBounds
and then try to call mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 15))
. Problem is when I use moveCamera()
method, I'm getting IllegalStateException
, but when I use animateCamera()
it goes just fine. I call both methods in onMapReady
callback. What is going on?
My stacktrace (main part):
java.lang.IllegalStateException: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view. Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions.
How is it possible that one method knows map size and the other one not?