コード例 #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.Id.ToString());
            if (annotationView == null)
            {
                annotationView                               = new CustomMKAnnotationView(annotation, customPin.Id.ToString());
                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);
                ((CustomMKAnnotationView)annotationView).Id  = customPin.Id.ToString();
                ((CustomMKAnnotationView)annotationView).Url = customPin.Url;
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
コード例 #2
0
		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 CustomMKAnnotationView(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);
				((CustomMKAnnotationView)annotationView).Id = customPin.Id;
				((CustomMKAnnotationView)annotationView).Url = customPin.Url;
			}
			annotationView.CanShowCallout = true;

			return annotationView;
		}
コード例 #3
0
        /// <summary>
        /// Se hace el detalle visual del marker (annotation)
        /// </summary>
        /// <returns>The view for annotation.</returns>
        /// <param name="mapView">Map view.</param>
        /// <param name="annotation">Annotation.</param>
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation is MKUserLocation)
            {
                return(null);
            }
            var anno = annotation as MKPointAnnotation;

            if (anno.Title == "Ud esta aqui")
            {
                annotationView       = new CustomMKAnnotationView(annotation, "aqui");
                annotationView.Image = UIImage.FromFile("pinaqui.png");
                annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("pinaqui.png"));
            }
            else
            {
                annotationView       = new CustomMKAnnotationView(annotation, "ecobici");
                annotationView.Image = UIImage.FromFile("ecobici.png");
                annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("ecobici.png"));
            }
            annotationView.CalloutOffset                = new CGPoint(0, 0);
            annotationView.RightCalloutAccessoryView    = UIButton.FromType(UIButtonType.DetailDisclosure);
            ((CustomMKAnnotationView)annotationView).Id = "pin";
            annotationView.CanShowCallout               = true;
            return(annotationView);
        }
コード例 #4
0
        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 CustomMKAnnotationView(annotation, customPin.Id)
                {
                    Image                     = GenerateImage(customPin.Id),
                    CalloutOffset             = new CGPoint(0, 0),
                    LeftCalloutAccessoryView  = new UIImageView(UIImage.FromFile("monkey.png")),
                    RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure)
                };
                ((CustomMKAnnotationView)annotationView).Id  = customPin.Id;
                ((CustomMKAnnotationView)annotationView).Url = customPin.Url;
            }
            annotationView.CanShowCallout = true;
            return(annotationView);
        }
コード例 #5
0
        void OnCalloutAccessoryControlTapped(object sender, MKMapViewAccessoryTappedEventArgs e)
        {
            CustomMKAnnotationView customView = e.View as CustomMKAnnotationView;

            if (!string.IsNullOrWhiteSpace(customView.Url))
            {
                UIApplication.SharedApplication.OpenUrl(new Foundation.NSUrl(customView.Url));
            }
        }
コード例 #6
0
 /*
  * Creates a new Hospital pin
  */
 private MKAnnotationView CreateHospitalPin(MKAnnotationView annotationView, CustomPin customPin, IMKAnnotation annotation)
 {
     annotationView               = new CustomMKAnnotationView(annotation, customPin.Id.ToString());
     annotationView.Image         = UIImage.FromFile("hospital_icon.png").Scale(new CGSize(45, 45));
     annotationView.CalloutOffset = new CGPoint(0, 0);
     ((CustomMKAnnotationView)annotationView).Id  = customPin.Id.ToString();
     ((CustomMKAnnotationView)annotationView).Url = customPin.Url;
     return(annotationView);
 }
コード例 #7
0
        /*
         * Creates a new helicopter pin
         */
        private MKAnnotationView CreateHelicopterPin(MKAnnotationView annotationView, CustomPin customPin, IMKAnnotation annotation)
        {
            refreshFlightDetails(customPin);

            annotationView               = new CustomMKAnnotationView(annotation, customPin.Id.ToString());
            annotationView.Image         = UIImage.FromFile(helicopterIcons[customPin.OrganToTransport]).Scale(new CGSize(45, 45));
            annotationView.CalloutOffset = new CGPoint(0, 0);
            ((CustomMKAnnotationView)annotationView).Id  = customPin.Id.ToString();
            ((CustomMKAnnotationView)annotationView).Url = customPin.Url;
            return(annotationView);
        }
コード例 #8
0
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

            if (annotation == null)
            {
                return(annotationView);
            }

            if (annotation is MKUserLocation)
            {
                return(null);
            }

            var anno = annotation as MKPointAnnotation;

            if (anno == null)
            {
                return(null);
            }
            var customPin = GetCustomPin(anno);

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

            annotationView = mapView.DequeueReusableAnnotation(customPin.Id);
            if (annotationView == null)
            {
                annotationView = new CustomMKAnnotationView(annotation, customPin.Id);
                if (customPin.Id == "Driver")
                {
                    annotationView.Image = UIImage.FromFile("driver_pin.png");
                }
                else if (customPin.Id == "Pick Up Location")
                {
                    annotationView.Image = UIImage.FromFile("pick_up_pin.png");
                }
                else
                {
                    annotationView.Image = UIImage.FromFile("drop_off_pin.png");
                }

                ((CustomMKAnnotationView)annotationView).Id       = customPin.Id;
                ((CustomMKAnnotationView)annotationView).isCustom = customPin.isCustom;
            }
            annotationView.CanShowCallout = true;

            return(annotationView);
        }
コード例 #9
0
        void OnDidSelectAnnotationView(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);
            }
        }
コード例 #10
0
        /*
         * Creates a receiver pin
         */
        private MKAnnotationView CreateReceiverPin(MKAnnotationView annotationView, CustomPin customPin, IMKAnnotation annotation)
        {
            annotationView               = new CustomMKAnnotationView(annotation, customPin.Id.ToString());
            annotationView.Image         = UIImage.FromFile(customPin.genderIcon).Scale(new CGSize(70, 70));
            annotationView.CalloutOffset = new CGPoint(0, 0);
            //Set image to profile photo

            var imageBytes = Convert.FromBase64String(customPin.userPhoto);
            var imageData  = NSData.FromArray(imageBytes);

            annotationView.LeftCalloutAccessoryView      = new UIImageView(UIImage.LoadFromData(imageData).Scale(new CGSize(40, 40)));
            ((CustomMKAnnotationView)annotationView).Id  = customPin.Id.ToString();
            ((CustomMKAnnotationView)annotationView).Url = customPin.Url;
            //annotationView.Set(true, true);
            return(annotationView);
        }