public DistTravelledViewModel(IWalkNavService navService) : base(navService) { this.Hours = 0; this.Minutes = 0; this.Seconds = 0; this.Travelled = 100; myLocation = DependencyService.Get <IWalkLocationService>(); myLocation.MyLocation += (object sender, IWalkCoordinates e) => { // Determine Distance Travelled if (_walkEntry != null && myLocation != null) { var distance = myLocation.GetDistanceTravelled(_walkEntry.Latitude, _walkEntry.Longitude); this.Travelled = distance; } }; myLocation.GetMyLocation(); }
async Task ExecuteSaveCommand() { var newWalkItem = new WalkEntries { Title = this.Title, Notes = this.Notes, Latitude = this.Latitude, Longitude = this.Longitude, Kilometers = this.Kilometers, Difficulty = this.Difficulty, Distance = this.Distance, ImageUrl = this.ImageUrl }; // Upon exiting our New Walk Entry Page, we need to // stop checking for location updates myLocation = null; // Here, we will save the details entered in a later chapter. await NavService.PreviousPage(); }
public WalkEntryViewModel(IWalkNavService navService) : base(navService) { Title = "New Walk"; Difficulty = "Easy"; Distance = 1.0; // Get our Location Service myLocation = DependencyService.Get <IWalkLocationService>(); // Check to ensure that we have a value for our object if (myLocation != null) { myLocation.MyLocation += (object sender, IWalkCoordinates e) => { // Obtain our Latitude and Longitude coordinates Latitude = e.latitude; Longitude = e.longitude; }; } // Call our Service to get our GPS location myLocation.GetMyLocation(); }