public override void OnLocationResult(LocationResult result)
        {
            base.OnLocationResult(result);
            if (result.LastLocation != null)
            {
                Location location = new Location()
                {
                    Latitude  = result.LastLocation.Latitude,
                    Longitude = result.LastLocation.Longitude,
                    Speed     = (int)Math.Round(result.LastLocation.Speed * 2.23694), // convert to mph
                    Heading   = (int)result.LastLocation.Bearing
                };
                //TODO: update location only when location changed
                LocationUpdatesEvent?.Invoke(this, location);

                if (_geolocationListener != null)
                {
                    _geolocationListener.OnLocationUpdated(location);
                }
            }
        }
 public Task StartUpdatingLocationAsync()
 {
     if (CLLocationManager.LocationServicesEnabled)
     {
         Location location = new Location();
         _locationManager.DesiredAccuracy   = 1;
         _locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) =>
         {
             location.Latitude  = e.Locations.Last().Coordinate.Latitude;
             location.Longitude = e.Locations.Last().Coordinate.Longitude;
             location.Speed     = (int)Math.Round(e.Locations.Last().Speed * 2.23694); // convert to mph
             // fire a custom event
             LocationUpdatesEvent?.Invoke(this, location);
         };
         _locationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) =>
         {
             location.Heading = (int)e.NewHeading.TrueHeading;
             //LocationUpdatesEvent?.Invoke(this, location);
         };
         _locationManager.StartUpdatingLocation();
         _locationManager.StartUpdatingHeading();
     }
     return(Task.CompletedTask);
 }