Example #1
0
        /// <summary>
        /// This is very much like the GetCell method on the table delegate
        /// </summary>
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            // try and dequeue the annotation view
            MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(annotationIdentifier);

            // if we couldn't dequeue one, create a new one
            if (annotationView == null)
            {
                annotationView = new MKPinAnnotationView(annotation, annotationIdentifier);
            }
            else // if we did dequeue one for reuse, assign the annotation to it
            {
                annotationView.Annotation = annotation;
            }
            // configure our annotation view properties
            annotationView.CanShowCallout = true;
            (annotationView as MKPinAnnotationView).AnimatesDrop = true;
            if (color == 1)
            {
                (annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Green;
            }
            else if (color == 2)
            {
                (annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Red;
            }
            else
            {
                (annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Purple;
            }
            annotationView.Selected = true;
            // you can add an accessory view, in this case, we'll add a button on the right, and an image on the left
            detailButton = UIButton.FromType(UIButtonType.DetailDisclosure);
            detailButton.TouchUpInside += (s, e) =>
            {
                Console.WriteLine("Clicked");
                //Create Alert
                var detailAlert = UIAlertController.Create("Binduraj Chandrasekaran", "415 516 1334", UIAlertControllerStyle.Alert);

                detailAlert.AddAction(UIAlertAction.Create("REQUEST HELP", UIAlertActionStyle.Default, (action) =>
                {
                    NexmoDataService nexmo = new NexmoDataService();
                    nexmo.VoiceCall("19256993334", "12016728509");
                }));

                detailAlert.AddAction(UIAlertAction.Create("CALL", UIAlertActionStyle.Default, (action) => {
                    NexmoDataService nexmo = new NexmoDataService();
                    nexmo.VoiceCall("19256993334", "12016728509");
                }));
                detailAlert.AddAction(UIAlertAction.Create("SMS", UIAlertActionStyle.Default, (action) => {
                    NexmoDataService nexmo = new NexmoDataService();
                    nexmo.SMS("19256993334", "12016728509");
                }));
                detailAlert.AddAction(UIAlertAction.Create("CANCEL", UIAlertActionStyle.Cancel, null));
                parent.PresentViewController(detailAlert, true, null);
            };
            annotationView.RightCalloutAccessoryView = detailButton;
            annotationView.LeftCalloutAccessoryView  = new UIImageView(UIImage.FromBundle("firstresponder.png"));
            return(annotationView);
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Rescuers";


            mapView = new MKMapView(View.Bounds);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
            mapView.MapType          = MKMapType.Hybrid;
            View.AddSubview(mapView);
            locationManager.RequestWhenInUseAuthorization();

            if (CLLocationManager.LocationServicesEnabled)
            {
                mapView.ShowsUserLocation = true;

                locationManager.StartMonitoringSignificantLocationChanges();
                locationManager.StartUpdatingLocation();
            }


            NexmoDataService service = new NexmoDataService();

            service.SMS("19256993334", "12016728509");

            MapDelegate.color = 1;

            // create our location and zoom for los angeles
            var rcoords = new CLLocationCoordinate2D(37.774628, -122.387341);             // paris
            var span    = new MKCoordinateSpan(MilesToLatitudeDegrees(0.7), MilesToLongitudeDegrees(0.7, rcoords.Latitude));

            // set the coords and zoom on the map
            mapView.Region = new MKCoordinateRegion(rcoords, span);


            PersonDataService persons = new PersonDataService();

            foreach (var person in persons.GetAllPerson())
            {
                mapView.AddAnnotation(new MKPointAnnotation()
                {
                    Title      = person.Name,
                    Subtitle   = person.PhoneNumber + " - Available",
                    Coordinate = new CLLocationCoordinate2D(person.latitude, person.longitude)
                });
            }



            // assign the delegate, which handles annotation layout and clicking
            mapView.Delegate = new MapDelegate(this);


            // add a basic annotation
            var annotation = new BasicMapAnnotation(new CLLocationCoordinate2D(37.774628, -122.387341), "Binduraj Chandrasekaran", "415 533 1764");

            mapView.AddAnnotation(annotation);
            btnBack.TouchUpInside += (sender, e) => {
                this.DismissViewController(true, null);
            };
        }