Xamarin Android Map Renderer Exception 2.3.4

ClayZuvichClayZuvich USMember ✭✭✭

I'm getting an exception while invoking the MoveToRegion call. It looks like it is internal. Has anyone else seen this?

Xamarin.Forms MapRenderer: MoveToRegion exception: 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. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00084] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11643 at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/JNIEnv.g.cs:264 at Android.Gms.Maps.GoogleMap.AnimateCamera (Android.Gms.Maps.CameraUpdate update) [0x0004a] in <cede2ee4138a48bb98b62dcaee115663>:0 at Xamarin.Forms.Maps.Android.MapRenderer.MoveToRegion (Xamarin.Forms.Maps.MapSpan span, System.Boolean animate) [0x000bc] in <2618a598256e482fb84a3a29a95fd7c3>:0 --- End of managed Java.Lang.IllegalStateException stack trace --- 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. at com.google.maps.api.android.lib6.common.k.a(:com.google.android.gms.DynamiteModulesB:131) at com.google.maps.api.android.lib6.gmm6.api.a.a(:com.google.android.gms.DynamiteModulesB:345) at com.google.maps.api.android.lib6.impl.aa.a(:com.google.android.gms.DynamiteModulesB:195) at com.google.maps.api.android.lib6.gmm6.api.a.a(:com.google.android.gms.DynamiteModulesB:172) at com.google.maps.api.android.lib6.impl.az.b(:com.google.android.gms.DynamiteModulesB:825) at com.google.android.gms.maps.internal.l.onTransact(:com.google.android.gms.DynamiteModulesB:92) at android.os.Binder.transact(Binder.java:499) at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.animateCamera(Unknown Source) at com.google.android.gms.maps.GoogleMap.animateCamera(Unknown Source) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

Posts

  • JessLpezJessLpez USMember ✭✭

    Hi @ClayZuvich, did you get a solution for this?

  • ClayZuvichClayZuvich USMember ✭✭✭

    Nope. Android maps are just broken in Forms. Did you?

  • FilipLarssonFilipLarsson SEMember ✭✭
    edited October 2017

    I have a problem that this occurs sometimes after the screen has been turned off and turned on again after some time.

    I have this code but it still stops working. A view will never be drawn again afterwards even if I go back. The map has a width and height according to the log and the exception is not caught.

    try {
        Debug.WriteLine("Before MoveToRegion, width: " + map.Width + ", height: " + map.Height);
        if(map.Width != 0 && map.Height != 0) {
                map.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromMiles(0.3)));
        }
    } catch(Exception e) {
        Debug.WriteLine("Exception on MoveToRegion: " + e.Message);   
    }
    

    Log:
    [0:] Before MoveToRegion, width: 411, height: 692
    0:] Xamarin.Forms MapRenderer: MoveToRegion exception: Java.Lang.IllegalStateException: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0.

    Edit: It seems that this is an issue I get since the view will never be shown. map.VisibleRegion is null in that case, so I can prevent the Exception, but not the other error :(

  • CatNaisCatNais Member ✭✭

    I have the same exception. Any solution ??

Sign In or Register to comment.