public async Task<bool> AreWeThereYetAsync(LocationPoint desiredDestination)
        {
            var currentLocation = await _positionServiceService.GetCurrentPositionAsync();
            var hasDesiredLatitude = Math.Abs(desiredDestination.Latitude - currentLocation.Latitude) < 0.01;
            var hasDesiredLongitude = Math.Abs(desiredDestination.Longitude - currentLocation.Longitude) < 0.01;

            return hasDesiredLongitude && hasDesiredLatitude;
        }
Beispiel #2
0
		private async void ClickHandler (object sender, EventArgs e)
		{
			AndHUD.Shared.Show(this, maskType: MaskType.Clear);
			var destinationLatitude = Convert.ToDouble(_latitudeInput.Text);
			var destinationLongitude = Convert.ToDouble(_longitudeInput.Text);

			var enteredDestination = new LocationPoint (destinationLatitude, destinationLongitude);
			var isLocationCloseEnough = await _locationService.AreWeThereYetAsync (enteredDestination);
			_resultLabel.Text = isLocationCloseEnough ? "Yay we made it." : "Sorry we still have some way to go.";
			AndHUD.Shared.Dismiss();

		}
        private async void AreWeThereYetButtonOnTouchUpInside(object sender, EventArgs eventArgs)
        {
            BTProgressHUD.Show(maskType: ProgressHUD.MaskType.Gradient);
            AreWeThereYetButton.Enabled = false;
            var destinationLatitude = Convert.ToDouble(LatitudeTextField.Text);
            var destinationLongitude = Convert.ToDouble(LongitudeTextField.Text);
            var destinationLocation = new LocationPoint(destinationLatitude, destinationLongitude);
            var isLocationCloseEnough = await _locationService.AreWeThereYetAsync(destinationLocation);

            AnswerLabel.Text = isLocationCloseEnough ? "Yay we made it." : "Sorry we still have some way to go.";
            AreWeThereYetButton.Enabled = true;
            BTProgressHUD.Dismiss();
        }