private void OnDidDeselectAnnotationView(object sender, MKAnnotationViewEventArgs e) { CustomMKAnnotationView customView = e.View as CustomMKAnnotationView; //customPinView = new UIView(); //if (customView.Name.Equals("Xamarin")) //{ // customPinView.Frame = new CGRect(0, 0, 200, 84); // var image = new UIImageView(new CGRect(0, 0, 200, 84)); // image.Image = UIImage.FromFile("xamarin.png"); // customPinView.AddSubview(image); // customPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75)); // e.View.AddSubview(customPinView); //} }
protected override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation) { MKAnnotationView annotationView = null; if (annotation is MKUserLocation) { return(null); } var customPin = GetCustomPin(annotation as MKPointAnnotation); if (customPin == null) { //throw new Exception("Custom pin not found"); } else { if (annotationView == null) { annotationView = new CustomMKAnnotationView(annotation, customPin.Name == null ? "" : customPin.Name); UILabel label = new UILabel(); label.Text = customPin.Number == null ? "" : customPin.Number; label.TextColor = UIColor.Black; label.Frame = new CGRect(0, 0, 20, 20); label.TextAlignment = UITextAlignment.Center; UIView f = new UIView(); f.Frame = new CGRect(5, 5, 20, 20); f.Layer.CornerRadius = 10; f.BackgroundColor = UIColor.White; f.AddSubview(label); //Debug.WriteLine("INPUT COLOR: " + customPin.Color); //Debug.WriteLine("GET COLOR: " + GetPin(customPin.Color)); annotationView.Image = UIImage.FromFile(GetPin(customPin.Color)); //annotationView.CalloutOffset = new CGPoint(0, 0); //annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("monkey.png")); var icon = new UIButton(); icon.Frame = new CGRect(0, 0, 45, 45); icon.SetBackgroundImage(UIImage.FromFile("goIcon.png"), UIControlState.Normal); icon.TouchDown += Icon_TouchDown; icon.FocusGroupIdentifier = label.Text; annotationView.RightCalloutAccessoryView = icon; //((CustomMKAnnotationView)annotationView).Name = customPin.Name; //((CustomMKAnnotationView)annotationView).Url = customPin.Url; annotationView.AddSubview(f); } annotationView.CanShowCallout = true; } //annotationView = mapView.DequeueReusableAnnotation(customPin.Name); return(annotationView); }