protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); if (e.OldElement != null) { MKMapView oldMap = Control as MKMapView; if (oldMap != null) { oldMap.RemoveAnnotations(oldMap.Annotations); oldMap.GetViewForAnnotation = null; userLocationSubscription?.Dispose(); userLocationSubscription = null; } } if (e.NewElement != null) { formsMap = (MapCustomPin)e.NewElement; nativeMap = Control as MKMapView; nativeMap.GetViewForAnnotation = GetViewForAnnotation; userLocationSubscription = formsMap.WhenAnyValue(fm => fm.UserCurrentLocation).WhereNotNull().Subscribe(UserLocationSubscription, ex => Console.WriteLine(ex.Message)); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Maps.Map> e) { base.OnElementChanged(e); if (e.OldElement != null) { userLocationSubscription?.Dispose(); userLocationSubscription = null; } if (e.NewElement != null) { formsMap = (MapCustomPin)e.NewElement; nativeMap = Control; userLocationSubscription = formsMap.WhenAnyValue(fm => fm.UserCurrentLocation).WhereNotNull().Subscribe(UserLocationSubscription, ex => Console.WriteLine(ex.Message)); } }