Example #1
0
        protected override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var eventPin = GetEventPin(annotation as MKPointAnnotation);

            if (eventPin == null)
            {
                throw new Exception("Custom pin not found");
            }

            MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(eventPin.Name);

            if (annotationView == null)
            {
                annotationView = new EventMapMKAnnotationView(annotation, eventPin.Name)
                {
                    Image                     = UIImage.FromFile("pin.png"),
                    CalloutOffset             = new CGPoint(0, 0),
                    LeftCalloutAccessoryView  = new UIImageView(UIImage.FromFile("monkey.png")),
                    RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure)
                };
                ((EventMapMKAnnotationView)annotationView).Id = eventPin.EventId;
            }

            annotationView.CanShowCallout = true;

            return(annotationView);
        }
Example #2
0
        void OnCalloutAccessoryControlTapped(object sender, MKMapViewAccessoryTappedEventArgs e)
        {
            EventMapMKAnnotationView eventView = e.View as EventMapMKAnnotationView;

            if (!string.IsNullOrWhiteSpace(eventView.Url))
            {
                UIApplication.SharedApplication.OpenUrl(new Foundation.NSUrl(eventView.Url));
            }
        }
Example #3
0
        void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
        {
            EventMapMKAnnotationView customView = e.View as EventMapMKAnnotationView;

            eventPinView = new UIView();

            if (customView.Name.Equals("Xamarin"))
            {
                eventPinView.Frame = new CGRect(0, 0, 200, 84);
                var image = new UIImageView(new CGRect(0, 0, 200, 84))
                {
                    Image = UIImage.FromFile("xamarin.png")
                };
                eventPinView.AddSubview(image);
                eventPinView.Center = new CGPoint(0, -(e.View.Frame.Height + 75));
                e.View.AddSubview(eventPinView);
            }
        }