/// <summary> /// Set the image of the annotation view /// </summary> /// <param name="annotationView">The annotation view</param> /// <param name="pin">The forms pin</param> private async void UpdateImage(MKAnnotationView annotationView, TKCustomMapPin pin) { if (pin.Image != null) { // If this is the case, we need to get a whole new annotation view. if (annotationView.GetType() == typeof (MKPinAnnotationView)) { this.Map.RemoveAnnotation(annotationView.Annotation); this.Map.AddAnnotation(new TKCustomMapAnnotation(pin)); return; } UIImage image; if (pin.Image is FileImageSource) { image = await new FileImageSourceHandler().LoadImageAsync(pin.Image); } else { image = await new ImageLoaderSourceHandler().LoadImageAsync(pin.Image); } Device.BeginInvokeOnMainThread(() => { annotationView.Image = image; }); } else { var pinAnnotationView = annotationView as MKPinAnnotationView; if (pinAnnotationView != null) { pinAnnotationView.AnimatesDrop = true; if (pin.DefaultPinColor != Color.Default) { pinAnnotationView.PinTintColor = pin.DefaultPinColor.ToUIColor(); } else { pinAnnotationView.PinTintColor = UIColor.Red; } } } }