Example #1
0
        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");
            }

            annotationView = mapView.DequeueReusableAnnotation(customPin.Name);
            if (annotationView == null)
            {
                annotationView                              = new OzelMKAnnotationView(annotation, customPin.Name);
                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);
                ((OzelMKAnnotationView)annotationView).Name = customPin.Name;
                ((OzelMKAnnotationView)annotationView).Url  = customPin.Url;
            }
            annotationView.CanShowCallout = true;

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

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

            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);
            }
        }