animateCamera可以工作,而moveCamera不适用于GoogleMap-Android [英] animateCamera works and moveCamera doesn't for GoogleMap - Android
本文介绍了animateCamera可以工作,而moveCamera不适用于GoogleMap-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要移动相机以覆盖其上的所有标记.因此,我建立了LatLngBounds
,然后尝试调用mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 15))
.问题是当我使用moveCamera()
方法时,我会得到IllegalStateException
,但是当我使用animateCamera()
时,它就可以了.我在onMapReady
回调中调用了这两种方法.发生了什么事?
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?
推荐答案
查看全文