Exemplo n.º 1
0
        private void AddAnnotationFor(object item)
        {
            var annotation = CreateAnnotation(item);

            _annotations[item] = annotation;
            MapView.AddAnnotation(annotation);
        }
Exemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement == null)
            {
                return;
            }

            var uiView = new UIView(new CoreGraphics.CGRect(0, 0, 500, 700));

            SetNativeControl(uiView);

            var mapView = new MapView(Control.Bounds);

            mapView.SetCenterCoordinate(new CoreLocation.CLLocationCoordinate2D(40.81, -96.68), false);
            mapView.SetZoomLevel(11, false);

            mapView.AddAnnotation(new PointAnnotation
            {
                Coordinate = new CoreLocation.CLLocationCoordinate2D(40.81, -96.68),
                Title      = "Lincoln, NE",
                Subtitle   = "What-what"
            });

            uiView.AddSubview(mapView);
        }
        // Performs a natural language search for locations in the map's region that match the `searchBar`'s text.
        void PerformSearch()
        {
            var request = new MKLocalSearchRequest();

            request.NaturalLanguageQuery = SearchBar.Text;
            const double multiplier = RegionQueryDegreeMultiplier;
            var          querySpan  = new MKCoordinateSpan(MapView.Region.Span.LatitudeDelta * multiplier, MapView.Region.Span.LongitudeDelta * multiplier);

            request.Region = new MKCoordinateRegion(MapView.Region.Center, querySpan);

            var search        = new MKLocalSearch(request);
            var matchingItems = new List <MKMapItem> ();

            search.Start((response, error) => {
                MKMapItem[] mapItems = null;
                if (response != null)
                {
                    mapItems = response.MapItems ?? new MKMapItem[0];
                }

                foreach (var item in mapItems)
                {
                    matchingItems.Add(item);
                    var annotation        = new MKPointAnnotation();
                    annotation.Coordinate = item.Placemark.Coordinate;
                    annotation.Title      = item.Name;
                    MapView.AddAnnotation(annotation);
                }
            });
        }
Exemplo n.º 4
0
        void AddMapAnnotation()
        {
            var placePosition = viewModel.Position;

            MapView.AddAnnotation(
                new CLLocationCoordinate2D(placePosition.Latitude, placePosition.Longitude),
                WKInterfaceMapPinColor.Red
                );
        }
Exemplo n.º 5
0
        private void addAnnotations()
        {
            var allStops = db.getAllBusStops();

            foreach (BusStop stop in allStops)
            {
                MapView.AddAnnotation(new StopAnnotation(stop));
            }
        }
Exemplo n.º 6
0
        public void FillMap()
        {
            annots = storage.GetAllAnnotations();

            foreach (var annotation in annots)

            {
                MapView.AddAnnotation(annotation);
            }
        }
            public override void DidFinishLoadingMap(MapView mapView)
            {
                var annotation = new PointAnnotation();

                annotation.Coordinate = new CoreLocation.CLLocationCoordinate2D(30.266461, -97.748630);
                annotation.Title      = "Austin";
                annotation.Subtitle   = "Texas";

                mapView.AddAnnotation(annotation);
            }
Exemplo n.º 8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a MapView and set the coordinates/zoom
            mapView = new MapView(View.Bounds);
            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(45.520486, -122.673541), 11, false);

            // Set ourselves as the delegate
            mapView.Delegate = this;

            View.AddSubview(mapView);

            var coordinates = new [] {
                new CLLocationCoordinate2D(45.522585, -122.685699),
                new CLLocationCoordinate2D(45.534611, -122.708873),
                new CLLocationCoordinate2D(45.530883, -122.678833),
                new CLLocationCoordinate2D(45.547115, -122.667503),
                new CLLocationCoordinate2D(45.530643, -122.660121),
                new CLLocationCoordinate2D(45.533529, -122.636260),
                new CLLocationCoordinate2D(45.521743, -122.659091),
                new CLLocationCoordinate2D(45.510677, -122.648792),
                new CLLocationCoordinate2D(45.515008, -122.664070),
                new CLLocationCoordinate2D(45.502496, -122.669048),
                new CLLocationCoordinate2D(45.515369, -122.678489),
                new CLLocationCoordinate2D(45.506346, -122.702007),
                new CLLocationCoordinate2D(45.522585, -122.685699),
            };

            // Create our shape with the formatted coordinates array
            mapView.AddAnnotation(Polygon.WithCoordinates(coordinates, (nuint)coordinates.Length));

            // Add a point annotation
            mapView.AddAnnotation(new PointAnnotation {
                Coordinate = new CLLocationCoordinate2D(45.522585, -122.685699),
                Title      = "Sample",
                Subtitle   = "This is a sample!"
            });

            mapView.ShowAnnotations(mapView.Annotations, false);
        }
        void AddXamarinHQPinToMap()
        {
            var xamarinHQPointAnnotiation = new MKPointAnnotation
            {
                Title      = "Xamarin HQ",
                Coordinate = _xamarinHQCoordinates
            };

            MapView.AddAnnotation(xamarinHQPointAnnotiation);

            MapView.SelectedAnnotations = new MKPointAnnotation[] { xamarinHQPointAnnotiation };
        }
Exemplo n.º 10
0
        private void SetupAnnotation(WifiHotspot wifiHotspot)
        {
            var coords     = new CLLocationCoordinate2D(wifiHotspot.Coordinates.Latitude, wifiHotspot.Coordinates.Longitude);
            var annotation = new WifiHotspotMapAnnotation(coords,
                                                          wifiHotspot.Name,
                                                          wifiHotspot.Address.Street);

            if (!MapView.Annotations.Any())
            {
                SetupMap(coords);
            }
            MapView.AddAnnotation(annotation);
        }
Exemplo n.º 11
0
 void OnDidSelectAnnotationView(object sender, MKAnnotationViewEventArgs e)
 {
     if (e.View is WPinAnnotationView)
     {
         var calloutAnnotation = new WCalloutAnnotation {
             Coordinate         = e.View.Annotation.Coordinate,
             OriginalAnnotation = e.View.Annotation
         };
         MapView.AddAnnotation(calloutAnnotation);
         MapView.SelectAnnotation(calloutAnnotation, true);
         CurrentCalloutView = null;
     }
 }
Exemplo n.º 12
0
        void SetLocation()
        {
            var placeLocation = viewModel.Place.Geometry.Location;
            var coordinates   = new CLLocationCoordinate2D(placeLocation.Latitude, placeLocation.Longitude);

            ZoomInToMyLocation(coordinates);

            var placeAnnotation = new MKPointAnnotation {
                Coordinate = coordinates
            };

            MapView.AddAnnotation(placeAnnotation);
        }
Exemplo n.º 13
0
        async void ShowPath()
        {
            var inputController = new InputDataController();
            var data            = await inputController.GetListAsync(_jsonResult);

            var locations = new List <CLLocationCoordinate2D>();


            foreach (var item in data)
            {
                locations.Add(new CLLocationCoordinate2D()
                {
                    Latitude = item.Latitude, Longitude = item.Longitude
                });
            }
            MapView.RemoveAnnotations(MapView.Annotations);
            if (locations.Count > 0)
            {
                var polyline = MKPolyline.FromCoordinates(locations.ToArray());
                MapView.AddOverlay(polyline);

                var startLocation = new CLLocation(locations[0].Latitude,
                                                   locations[0].Longitude);
                var endLocation = new CLLocation(locations.Last().Latitude,
                                                 locations.Last().Longitude);
                var distance = startLocation.DistanceFrom(endLocation);


                var region = MKCoordinateRegion.FromDistance(locations[(locations.Count / 2)],
                                                             distance + 10000, distance + 10000);
                MapView.SetRegion(region, animated: false);

                var annoStart = new FlightAnnotation(title: "Starting point",
                                                     subtitle: "",
                                                     coordinate: locations[0]);
                MapView.AddAnnotation(annoStart);


                var annoEnd = new FlightAnnotation(title: "End point",
                                                   subtitle: "",
                                                   coordinate: locations.Last());
                annoEnd.TintColor = UIColor.Purple;

                MapView.AddAnnotation(annoEnd);
            }
        }
Exemplo n.º 14
0
        void Tapper(UITapGestureRecognizer press)
        {
            StockpileInfo info          = new StockpileInfo();
            var           pixelLocation = press.LocationInView(MapView);
            var           geoLocation   = MapView.ConvertPoint(pixelLocation, MapView);
            var           stockpile     = info.getStockPileNumber();
            var           company       = info.getCompany();

            if ((!string.IsNullOrEmpty(stockpile)) && (!string.IsNullOrEmpty(company)))
            {
                CoalAnnotation coalAn = new CoalAnnotation(stockpile, company, geoLocation);
                coalAn.IncrementId();
                storage.AddAnnotation(coalAn);

                MapView.AddAnnotation(coalAn);
                info.Clear();
            }
        }
Exemplo n.º 15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a MapView and set the coordinates/zoom
            mapView = new MapView(View.Bounds);
            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(45.520486, -122.673541), false);
            mapView.SetZoomLevel(11, false);

            // Add new annotation
//            mapView.AddAnnotation (new PointAnnotation {
//                Coordinate = new CLLocationCoordinate2D (40.7326808, -73.9843407),
//                Title = "Sample Marker",
//                Subtitle = "This is the subtitle"
//            });

            var coordinates = new [] {
                new CLLocationCoordinate2D(45.522585, -122.685699),
                new CLLocationCoordinate2D(45.534611, -122.708873),
                new CLLocationCoordinate2D(45.530883, -122.678833),
                new CLLocationCoordinate2D(45.547115, -122.667503),
                new CLLocationCoordinate2D(45.530643, -122.660121),
                new CLLocationCoordinate2D(45.533529, -122.636260),
                new CLLocationCoordinate2D(45.521743, -122.659091),
                new CLLocationCoordinate2D(45.510677, -122.648792),
                new CLLocationCoordinate2D(45.515008, -122.664070),
                new CLLocationCoordinate2D(45.502496, -122.669048),
                new CLLocationCoordinate2D(45.515369, -122.678489),
                new CLLocationCoordinate2D(45.506346, -122.702007),
                new CLLocationCoordinate2D(45.522585, -122.685699),
            };
            //nuint numberOfCoordinates = (nuint) (coordinates.Length /  sizeof(CLLocationCoordinate2D));

            // Create our shape with the formatted coordinates array
            var shape = Polygon.WithCoordinates(coordinates, (nuint)coordinates.Length);

            mapView.AddAnnotation(shape);

            // Set ourselves as the delegate
            mapView.Delegate = this;

            View.AddSubview(mapView);
        }
        public override void Refresh(ChallengeResponseModel challengeResponce)
        {
            base.Refresh(challengeResponce);

            if (challengeResponce == null)
            {
                return;
            }

            Challenge      = challengeResponce.Challenge;
            HeaderLbl.Text = Challenge.Name;
            //MainTextLable.Text = Challenge.Desc;
            TimeDisLbl.Text = Challenge.NextEventCountDown;

            var navigationDelegate = new ChallengeDetailWebViewNavigationDelegate();

            navigationDelegate.NavigationFinished += SetupConstraint;
            this.WebView.NavigationDelegate        = navigationDelegate;
            WebView.LoadHtmlString(Challenge.Desc, null);

            if (!DidSetupMap && Challenge.LocationLat != null && Challenge.LocationLong != null)
            {
                double radius = Challenge.RadiusMeters ?? 100.0;
                if (radius > 6000000)
                {
                    radius = 6000000;
                }
                double mapRegion = radius * 2.5;

                CLLocationCoordinate2D mapCoordinate = new CLLocationCoordinate2D(Challenge.LocationLat.Value, Challenge.LocationLong.Value);
                MapView.SetRegion(MKCoordinateRegion.FromDistance(mapCoordinate, mapRegion, mapRegion), true);

                MKCircle circle = MKCircle.Circle(mapCoordinate, radius);
                MapView.AddOverlay(circle);

                MKPointAnnotation annotation = new MKPointAnnotation();
                annotation.Coordinate = new CLLocationCoordinate2D(Challenge.LocationLat.Value, Challenge.LocationLong.Value);
                MapView.AddAnnotation(annotation);

                DidSetupMap = true;
            }
        }
Exemplo n.º 17
0
        private void AnnotationHandler(CLPlacemark[] placemarks, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine(error.LocalizedDescription);
            }

            if (placemarks != null)
            {
                var placemark  = placemarks[0];
                var annotation = new MKPointAnnotation();
                var location   = placemark.Location;
                if (location != null)
                {
                    annotation.Coordinate = location.Coordinate;
                    MapView.AddAnnotation(annotation);
                    var region = MKCoordinateRegion.FromDistance(annotation.Coordinate, 250, 250);
                    MapView.SetRegion(region, false);
                }
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            Title = "Trip";

            StartLabel.Text = TripLog.StartStation;
            EndLabel.Text   = TripLog.EndStation;
            TimeLabel.Text  = string.Format("{0}, {1}", TripLog.DistanceForDisplay, TripLog.TimeForDisplay);


            MapView.GetViewForAnnotation = delegate(MKMapView mapViewForAnnotation, NSObject annotation) {
                if (annotation is MKUserLocation)
                {
                    return(null);
                }

                if (annotation is PinAnnotation)
                {
                    var mapAnnotation = annotation as PinAnnotation;
                    if (mapAnnotation == null)
                    {
                        return(null);
                    }


                    MKPinAnnotationView pinView = (MKPinAnnotationView)mapViewForAnnotation.DequeueReusableAnnotation(MapPin);
                    if (pinView == null)
                    {
                        pinView = new MKPinAnnotationView(mapAnnotation, MapPin);
                    }
                    else
                    {
                        pinView.Annotation = annotation;
                    }

                    if (mapAnnotation.IsStart)
                    {
                        pinView.PinColor = MKPinAnnotationColor.Green;
                    }
                    else
                    {
                        pinView.PinColor = MKPinAnnotationColor.Red;
                    }

                    mapAnnotation.PinView = pinView;


                    pinView.CanShowCallout = true;
                    return(pinView);
                }



                return(null);
            };



            List <MKAnnotation> locations = new List <MKAnnotation>();

            double minLon = 200, minLat = 200, maxLon = -200, maxLat = -200;

            if (TripLog.StartLat != -1 && TripLog.StartLon != -1)
            {
                locations.Add(new PinAnnotation(TripLog.StartLat, TripLog.StartLon, TripLog.StartStation, true));
            }

            if (TripLog.EndLat != -1 && TripLog.EndLon != -1)
            {
                locations.Add(new PinAnnotation(TripLog.EndLat, TripLog.EndLon, TripLog.EndStation, false));
            }


            foreach (var location in locations)
            {
                if (location.Coordinate.Longitude < minLon)
                {
                    minLon = location.Coordinate.Longitude;
                }
                if (location.Coordinate.Latitude < minLat)
                {
                    minLat = location.Coordinate.Latitude;
                }

                if (location.Coordinate.Longitude < maxLon)
                {
                    maxLon = location.Coordinate.Longitude;
                }
                if (location.Coordinate.Latitude > maxLat)
                {
                    maxLat = location.Coordinate.Latitude;
                }
            }


            CLLocationCoordinate2D tl, br;

            if (locations.Count > 0)
            {
                MapView.AddAnnotation(locations.ToArray());



                tl = new CLLocationCoordinate2D(-90, 180);
                br = new CLLocationCoordinate2D(90, -180);

                foreach (MKAnnotation an in MapView.Annotations)
                {
                    tl.Longitude = Math.Min(tl.Longitude, an.Coordinate.Longitude);
                    tl.Latitude  = Math.Max(tl.Latitude, an.Coordinate.Latitude);

                    br.Longitude = Math.Max(br.Longitude, an.Coordinate.Longitude);
                    br.Latitude  = Math.Min(br.Latitude, an.Coordinate.Latitude);
                }
            }
            else
            {
                tl = new CLLocationCoordinate2D(51.5282, -0.1669);
                br = new CLLocationCoordinate2D(51.4898, -0.0680);
            }

            var center = new CLLocationCoordinate2D {
                Latitude  = tl.Latitude - (tl.Latitude - br.Latitude) * 0.5,
                Longitude = tl.Longitude - (tl.Longitude - br.Longitude) * 0.5
            };

            var span = new MKCoordinateSpan
            {
                LatitudeDelta  = Math.Abs(tl.Latitude - br.Latitude) * 1.05f,
                LongitudeDelta = Math.Abs(tl.Longitude - br.Longitude) * 1.05f
            };



            MKCoordinateRegion region = new MKCoordinateRegion(center, span);


            region = MapView.RegionThatFits(region);

            MapView.SetRegion(region, true);
        }
Exemplo n.º 19
0
        protected virtual void Update()
        {
            if (!m_firstUpdateComplete)
            {
                if (ForegroundPositionService.Instance.HasLocationData)
                {
                    if (Ready != null)
                    {
                        Ready.Invoke(new MapControllerEventArgs(ForegroundPositionService.Instance.Position));
                    }

                    m_userAnnotation             = new UserAnnotation();
                    m_userAnnotation.Coordinates = ForegroundPositionService.Instance.Position;

                    if (LockToUser)
                    {
                        LockOnUser(true);
                    }

                    MapView.AddAnnotation(m_userAnnotation);

                    var startCoords = m_startCoordinates ?? ForegroundPositionService.Instance.Position;
                    SetMapRegion(startCoords, ZoomLevel);
                    //m_startMapZoom = ZoomLevel;

                    m_firstUpdateComplete = true;
                }
            }
            else
            {
                // Add/remove any annotations on the correct thread
                if (m_toAdd.Count > 0)
                {
                    lock (m_toAdd)
                    {
                        var toAdd = m_toAdd.ToArray();
                        m_toAdd.Clear();

                        foreach (var ann in toAdd)
                        {
                            MapView.AddAnnotation(ann);
                        }
                    }
                }

                if (m_toRemove.Count > 0)
                {
                    lock (m_toRemove)
                    {
                        var toRemove = m_toRemove.ToArray();
                        m_toRemove.Clear();

                        foreach (var ann in toRemove)
                        {
                            MapView.RemoveAnnotation(ann);
                        }
                    }
                }

                // The map view will not necessarily re-check the coordinates unless the
                // told directly.
                m_userAnnotation.UpdateCoordinates(ForegroundPositionService.Instance.Position, Time.deltaTime);
                MapView.UpdateAnnotation(m_userAnnotation);

                if (m_lockAnnotation != null)
                {
                    SetMapRegion(m_lockAnnotation.Coordinates, MapView.Zoom);

                    if (MapInput.PointerDown && DeselectAnnotationOnMapInput)
                    {
                        SelectAnnotation(null);
                    }
                }
                else
                {
                    if (MapInput.IsTranslating)
                    {
                        m_panToCoordinates = null;
                        m_panToZoom        = null;

                        if (DeselectAnnotationOnMapInput)
                        {
                            SelectAnnotation(null);
                        }

                        if (MapInput.Translation.sqrMagnitude > 0)
                        {
                            var tx = -MapInput.Translation.x / (m_mapPixWidth);
                            var ty = MapInput.Translation.y / (m_mapPixWidth);

                            MapView.Translate(tx, ty);
                        }
                    }
                    else
                    {
                        //m_currTranslate = Vector2.zero;

                        if (m_panToCoordinates != null)
                        {
                            var         zoom        = MapView.Zoom == 0 ? ZoomLevel : MapView.Zoom;
                            Coordinates coordinates = null;

                            if (m_panDuration.HasValue)
                            {
                                // Use smoothstep for time-based transitions
                                var dt = Mathf.Min((Time.time - m_panStartTime) / m_panDuration.Value, 1f);

                                var delta = Mathf.SmoothStep(0, 1, dt);

                                coordinates = m_panStartCoordinates.Interpolate(m_panToCoordinates, delta);

                                if (m_panToZoom.HasValue)
                                {
                                    zoom = Mathf.SmoothStep((float)m_panStartZoom, (float)m_panToZoom, dt);
                                }
                            }
                            else
                            {
                                // Use exponential - good for general purpose as it takes longer over long
                                // distances
                                coordinates = MapView.CenterCoordinates.Approach(m_panToCoordinates, PanSpeed, Time.deltaTime);

                                if (m_panToZoom.HasValue)
                                {
                                    zoom = MathHelper.Approach(zoom, m_panToZoom.Value, PanSpeed, Time.deltaTime);
                                }
                            }

                            var dz = m_panToZoom.HasValue ? Math.Abs(zoom - m_panToZoom.Value) : 0;

                            SetMapRegion(coordinates, zoom);

                            if (coordinates.GetDistanceFrom(m_panToCoordinates) < 0.5 &&
                                dz < 0.1)
                            {
                                SetMapRegion(m_panToCoordinates, m_panToZoom ?? MapView.Zoom);

                                m_panToCoordinates = null;

                                if (m_onPanComplete != null)
                                {
                                    m_onPanComplete();
                                }
                            }
                        }
                    }
                }

                if (MapInput.IsPinching)
                {
                    SetMapRegion(MapView.CenterCoordinates, MapView.Zoom + MapInput.ZoomDelta);
                }
            }
        }
 protected virtual void AddAnnotationFor(object item)
 {
     var annotation = CreateAnnotation(item);
     _annotations[item] = annotation;
     MapView.AddAnnotation(annotation);
 }
        // This overridden method will be called after the AcquaintanceDetailViewController has been instantiated and loaded into memory,
        // but before the view hierarchy is rendered to the device screen.
        // The "async" keyword is added here to the override in order to allow other awaited async method calls inside the override to be called ascynchronously.
        public override async void ViewWillAppear(bool animated)
        {
            if (Acquaintance != null)
            {
                // set the title and label text properties
                Title = Acquaintance.DisplayName;
                CompanyNameLabel.Text    = Acquaintance.Company;
                JobTitleLabel.Text       = Acquaintance.JobTitle;
                StreetLabel.Text         = Acquaintance.Street;
                CityLabel.Text           = Acquaintance.City;
                StateAndPostalLabel.Text = Acquaintance.StatePostal;
                PhoneLabel.Text          = Acquaintance.Phone;
                EmailLabel.Text          = Acquaintance.Email;

                // Set image views for user actions.
                // The action for getting navigation directions is setup further down in this method, after the geocoding occurs.
                SetupSendMessageAction();
                SetupDialNumberAction();
                SetupSendEmailAction();

                // use FFImageLoading library to asynchronously:
                await ImageService.Instance
                .LoadFileFromApplicationBundle(String.Format(Acquaintance.PhotoUrl))                            // get the image from the app bundle
                .LoadingPlaceholder("placeholderProfileImage.png")                                              // specify a placeholder image
                .Transform(new CircleTransformation())                                                          // transform the image to a circle
                .IntoAsync(ProfilePhotoImageView);                                                              // load the image into the UIImageView

                // use FFImageLoading library to asynchronously:
                //	await ImageService
                //		.LoadUrl(Acquaintance.PhotoUrl)                     // get the image from a URL
                //		.LoadingPlaceholder("placeholderProfileImage.png")  // specify a placeholder image
                //		.Transform(new CircleTransformation())              // transform the image to a circle
                //		.IntoAsync(ProfilePhotoImageView);                  // load the image into the UIImageView


                // The FFImageLoading library has nicely transformed the image to a circle, but we need to use some iOS UIKit and CoreGraphics API calls to give it a colored border.
                double min = Math.Min(ProfilePhotoImageView.Frame.Height, ProfilePhotoImageView.Frame.Height);
                ProfilePhotoImageView.Layer.CornerRadius  = (float)(min / 2.0);
                ProfilePhotoImageView.Layer.MasksToBounds = false;
                ProfilePhotoImageView.Layer.BorderColor   = UIColor.FromRGB(84, 119, 153).CGColor;
                ProfilePhotoImageView.Layer.BorderWidth   = 5;
                ProfilePhotoImageView.BackgroundColor     = UIColor.Clear;
                ProfilePhotoImageView.ClipsToBounds       = true;

                try
                {
                    // asynchronously geocode the address
                    var locations = await _Geocoder.GeocodeAddressAsync(Acquaintance.AddressString);

                    // if we have at least one location
                    if (locations != null && locations.Length > 0)
                    {
                        var coord = locations[0].Location.Coordinate;

                        var span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coord.Latitude));

                        // set the region that the map should display
                        MapView.Region = new MKCoordinateRegion(coord, span);

                        // create a new pin for the map
                        var pin = new MKPointAnnotation()
                        {
                            Title      = Acquaintance.DisplayName,
                            Coordinate = new CLLocationCoordinate2D()
                            {
                                Latitude  = coord.Latitude,
                                Longitude = coord.Longitude
                            }
                        };

                        // add the pin to the map
                        MapView.AddAnnotation(pin);

                        // add a top border to the MapView
                        MapView.Layer.AddSublayer(new CALayer()
                        {
                            BackgroundColor = UIColor.LightGray.CGColor,
                            Frame           = new CGRect(0, 0, MapView.Frame.Width, 1)
                        });

                        // setup fhe action for getting navigation directions
                        SetupGetDirectionsAction(coord.Latitude, coord.Longitude);
                    }
                } catch
                {
                    //DisplayErrorAlertView("Geocoding Error", "Please make sure the address is valid and that you have a network connection.");
                }
            }
        }
        // This overridden method will be called after the AcquaintanceDetailViewController has been instantiated and loaded into memory,
        // but before the view hierarchy is rendered to the device screen.
        // The "async" keyword is added here to the override in order to allow other awaited async method calls inside the override to be called ascynchronously.
        public override async void ViewWillAppear(bool animated)
        {
            if (TeamMemberLite == null)
            {
                return;
            }

            Title = TeamMemberLite.DisplayName;
            CompanyNameLabel.Text = TeamMemberLite.Company;
            JobTitleLabel.Text    = TeamMemberLite.JobTitle;

            teamMember = await teamMemberService.Get(TeamMemberLite);

            if (teamMember != null)
            {
                // set the title and label text properties

                StreetLabel.Text         = teamMember.Street;
                CityLabel.Text           = teamMember.City;
                StateAndPostalLabel.Text = teamMember.StatePostal;
                PhoneLabel.Text          = teamMember.Phone;
                EmailLabel.Text          = teamMember.Email;

                // Set image views for user actions.
                // The action for getting navigation directions is setup further down in this method, after the geocoding occurs.
                SetupSendMessageAction();
                SetupDialNumberAction();
                SetupSendEmailAction();

                GetDirectionsImageView.Image = UIImage.FromBundle("directions");
                // use FFImageLoading library to asynchronously:
                await ImageService
                .Instance
                .LoadUrl(teamMember.PhotoUrl, TimeSpan.FromHours(Settings.ImageCacheDurationHours)) // get the image from a URL
                .LoadingPlaceholder("placeholderProfileImage.png")                                  // specify a placeholder image
                .Transform(new CircleTransformation())                                              // transform the image to a circle
                .Error(e => System.Diagnostics.Debug.WriteLine(e.Message))
                .IntoAsync(ProfilePhotoImageView);                                                  // load the image into the UIImageView

                try {
                    // asynchronously geocode the address
                    var locations = await _Geocoder.GeocodeAddressAsync(teamMember.AddressString);

                    // if we have at least one location
                    if (locations != null && locations.Length > 0)
                    {
                        var coord = locations[0].Location.Coordinate;

                        var span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coord.Latitude));

                        // set the region that the map should display
                        MapView.Region = new MKCoordinateRegion(coord, span);

                        // create a new pin for the map
                        var pin = new MKPointAnnotation()
                        {
                            Title      = TeamMemberLite.DisplayName,
                            Coordinate = new CLLocationCoordinate2D()
                            {
                                Latitude  = coord.Latitude,
                                Longitude = coord.Longitude
                            }
                        };

                        // add the pin to the map
                        MapView.AddAnnotation(pin);

                        // add a top border to the MapView
                        MapView.Layer.AddSublayer(new CALayer()
                        {
                            BackgroundColor = UIColor.LightGray.CGColor,
                            Frame           = new CGRect(0, 0, MapView.Frame.Width, 1)
                        });

                        // setup fhe action for getting navigation directions
                        SetupGetDirectionsAction(coord.Latitude, coord.Longitude);
                    }
                } catch {
                    DisplayErrorAlertView("Geocoding Error", "Please make sure the address is valid and that you have a network connection.");
                }
            }
        }