相关疑难解决方法(0)

使用CameraUpdateFactory.newLatLngBounds崩溃的moveCamera

我正在使用新的Android Google Maps API.

我创建了一个包含MapFragment的活动.在活动中,onResume我将标记设置为GoogleMap对象,然后为地图定义包含所有标记的边界框.

这是使用以下伪代码:

LatLngBounds.Builder builder = new LatLngBounds.Builder();
while(data) {
   LatLng latlng = getPosition();
   builder.include(latlng);
}
CameraUpdate cameraUpdate = CameraUpdateFactory
   .newLatLngBounds(builder.build(), 10);
map.moveCamera(cameraUpdate);
Run Code Online (Sandbox Code Playgroud)

调用map.moveCamera()导致我的应用程序崩溃与以下堆栈:

Caused by: java.lang.IllegalStateException: 
    Map size should not be 0. Most likely, layout has not yet 

    at maps.am.r.b(Unknown Source)
    at maps.y.q.a(Unknown Source)
    at maps.y.au.a(Unknown Source)
    at maps.y.ae.moveCamera(Unknown Source)
    at com.google.android.gms.maps.internal.IGoogleMapDelegate$Stub
        .onTransact(IGoogleMapDelegate.java:83)
    at android.os.Binder.transact(Binder.java:310)
    at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a
        .moveCamera(Unknown Source)
    at com.google.android.gms.maps.GoogleMap.moveCamera(Unknown Source)
    at ShowMapActivity.drawMapMarkers(ShowMapActivity.java:91)
    at ShowMapActivity.onResume(ShowMapActivity.java:58)
    at android.app.Instrumentation
        .callActivityOnResume(Instrumentation.java:1185)
    at …
Run Code Online (Sandbox Code Playgroud)

android android-mapview google-maps-android-api-2

94
推荐指数
9
解决办法
8万
查看次数

IllegalStateException映射大小不应为0

我有一个MapFragment显示地图

如果用户随地图离开活动(或设备进入睡眠状态)然后返回onResume被调用,我将地图移回标记.

但是当我移动相机时,我得到一个例外

07-23 16:28:42.725: E/AndroidRuntime(19095): java.lang.RuntimeException: Unable to resume activity {ecm2.android/ecm2.android.EMGNoteMapActivity}: java.lang.IllegalStateException: Map size should not be 0. Most likely, layout has not yet occured for the map view.
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
 07-23 16:28:42.725: E/AndroidRuntime(19095):   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.os.Looper.loop(Looper.java:137)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at android.app.ActivityThread.main(ActivityThread.java:5041)
07-23 16:28:42.725: E/AndroidRuntime(19095):    at java.lang.reflect.Method.invokeNative(Native Method) …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-android-api-2

7
推荐指数
1
解决办法
1万
查看次数