Hello!
I'm currently working on a Xamarin.Forms app that needs to display map markers with clickable info windows to navigate to another screen. Since Xamarin.Forms.Maps.Map doesn't have a PinSelected event yet, I'm creating a Xamarin.Forms.View subclass and using a ViewRenderer to set a Android.Gms.Maps.MapView object as the NativeControl for the renderer.
I'm managed to get this to work, but I'm running into the following problem. The custom map is (wrapped in a NavigationPage) the default page in a MasterDetailPage. It loads correctly when I new up the MasterDetailPage, but when navigate elsewhere and click on the menu option to bring the custom map page back it throws the following exception, which wasn't happening when I was simply displaying the Xamarin.Forms.Maps.Map on that page, so I'm assuming it has to do with using a ViewRenderer.
Any suggestions? I assume this has to do with reusing the same view, since I'm holding the MapView as a static member of the MainActivity in the Android project. ( So I can send host activity lifecycle methods to the MapView, otherwise I just get a blank map. )
Unhandled Exception:
Java.Lang.IllegalStateException: Exception of type 'Java.Lang.IllegalStateException' was thrown.
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) <0x001ac>
at Android.Views.ViewGroup.AddView (Android.Views.View,int) <0x002af>
at Xamarin.Forms.Platform.Android.ViewRenderer
2<WonoloXamarin.WonoloMap, WonoloXamarin.Android.WonoloMapView>.SetNativeControl (WonoloXamarin.Android.WonoloMapView) <0x00093>
at WonoloXamarin.Android.WonoloMapRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs
1<WonoloXamarin.WonoloMap>) <0x0003f>at Xamarin.Forms.Platform.Android.VisualElementRenderer
1<WonoloXamarin.WonoloMap>.SetElement (WonoloXamarin.WonoloMap) <0x002db>
at Xamarin.Forms.Platform.Android.VisualElementRenderer
1<WonoloXamarin.WonoloMap>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement) <0x00063>at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.