private MKAnnotationView OnGetViewForAnnotation(MKMapView mapView, AnnotationAlias annotation) { if (annotation is MapControlAnnotation mapAnnotation) { var annotationView = mapView.DequeueReusableAnnotation(MapControlAnnotation.AnnotationId); if (annotationView == null) { annotationView = new MKAnnotationView(mapAnnotation, MapControlAnnotation.AnnotationId); annotationView.Add(mapAnnotation.Content); } if (mapAnnotation.Content is FrameworkElement element) { element.Measure(new Size((float)Bounds.Width, (float)Bounds.Height)); var size = element.DesiredSize; element.Arrange(new Rect(0, 0, size.Width, size.Height)); // Set the frame size, or the pin will not be selectable. annotationView.Frame = new CoreGraphics.CGRect(0, 0, size.Width, size.Height); mapAnnotation.Content.Frame = new CoreGraphics.CGRect(0, 0, size.Width, size.Height); } return annotationView; } return null; }
public override MapKit.MKAnnotationView GetViewForAnnotation(MapKit.MKMapView mapView, MapKit.IMKAnnotation annotation) { var annotationView = base.GetViewForAnnotation(mapView, annotation); if (annotationView == null) { return(null); } var customAnnotation = GetPinByAnnotation(annotation); annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("Icon-60.png")); return(annotationView); }
public override MapKit.MKAnnotationView GetViewForAnnotation(MapKit.MKMapView mapView, MapKit.IMKAnnotation annotation) { System.Diagnostics.Debug.WriteLine("===========MKAnnotationView=============="); var annotationView = base.GetViewForAnnotation(mapView, annotation); if (annotationView == null) { return(null); } var customAnnotation = GetPinByAnnotation(annotation); //annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("Icon-60.png")); return(annotationView); }