MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKAnnotationView annotationView = null; if (annotation is MKUserLocation) { return(null); } var anno = annotation as MKPointAnnotation; var customPin = GetCustomPin(anno); if (customPin == null) { throw new Exception("Custom pin not found"); } annotationView = mapView.DequeueReusableAnnotation(customPin.Id); if (annotationView == null) { annotationView = new CustomMKPinAnnotationView(annotation, customPin.Id); annotationView.Image = UIImage.FromFile("pin.png"); annotationView.CalloutOffset = new CGPoint(0, 0); annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("monkey.png")); annotationView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure); ((CustomMKPinAnnotationView)annotationView).Id = customPin.Id; ((CustomMKPinAnnotationView)annotationView).Url = customPin.Url; } annotationView.CanShowCallout = true; return(annotationView); }
MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation) { MKAnnotationView annotationView = null; if (annotation is MKUserLocation) return null; var anno = annotation as MKPointAnnotation; var customPin = GetCustomPin (anno); if (customPin == null) { throw new Exception ("Custom pin not found"); } annotationView = mapView.DequeueReusableAnnotation (customPin.Id); if (annotationView == null) { annotationView = new CustomMKPinAnnotationView (annotation, customPin.Id); annotationView.Image = UIImage.FromFile ("pin.png"); annotationView.CalloutOffset = new CGPoint (0, 0); annotationView.LeftCalloutAccessoryView = new UIImageView (UIImage.FromFile ("monkey.png")); annotationView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure); ((CustomMKPinAnnotationView)annotationView).Id = customPin.Id; ((CustomMKPinAnnotationView)annotationView).Url = customPin.Url; } annotationView.CanShowCallout = true; return annotationView; }