【发布时间】:2019-06-07 21:59:31
【问题描述】:
我需要移动相机以覆盖其上的所有标记。所以,我构建了LatLngBounds,然后尝试调用mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 15))。问题是当我使用moveCamera() 方法时,我得到IllegalStateException,但是当我使用animateCamera() 时,它运行得很好。我在onMapReady 回调中调用了这两种方法。怎么回事?
我的堆栈跟踪(主要部分):
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.
怎么可能一种方法知道地图大小而另一种方法不知道?
【问题讨论】:
标签: android google-maps illegalstateexception