Ejemplo n.º 1
0
 public void DidSelectAnnotationView(MKMapView mapView, MKAnnotationView view)
 {
     if (view.Annotation is LocationAnnotation)
     {
         _lastSelectedLocationAnnotation = view.Annotation as LocationAnnotation;
         //TODO: Navigate to the ShipDocumentViewController and highlight the location within it.
         this.PerformSegue("ShowShipDocumentSegue", this);
     }
 }
Ejemplo n.º 2
0
        async void RefreshWithLocations()
        {
            //Load all the locations for this ship.
            var dataAccess = TinyIoC.TinyIoCContainer.Current.Resolve <IDataAccess>();
            var locations  = await dataAccess.GetLocationsForShip(this.Ship);

            var shipLocations = await dataAccess.GetRawGeolocationsForShip(this.Ship);

            foreach (var location in shipLocations)
            {
                if (location.LocationGeocodeResult != null)
                {
                    //Only plot the first result.
                    var result = location.LocationGeocodeResult.Results.FirstOrDefault();
                    if (result == null)
                    {
                        continue;
                    }
                    var geometry = result.Geometry;
                    if (geometry != null && geometry.Viewport != null)
                    {
                        var val = geometry.Viewport.Values.FirstOrDefault();

                        if (val == null)
                        {
                            continue;
                        }

                        var lat       = val.Lat;
                        var longitude = val.Long;

                        var annotation = new LocationAnnotation();
                        annotation.SetCoordinate(new CoreLocation.CLLocationCoordinate2D(lat, longitude));
                        annotation.Title                     = location.Location + "-" + location.PossibleStartDate.GetValueOrDefault() + "-" + location.PossibleEndDate.GetValueOrDefault();
                        annotation.LocationIndex             = location.LocationIndex;
                        annotation.LocationGuid              = location.LocationGuid;
                        annotation.GeocodeResult             = location.LocationGeocodeResult;
                        annotation.ShipLocationHistoryResult = location;
                        this.locationMapView.AddAnnotation(annotation);
                    }
                }
            }
        }