private async Task GeoTagPhotoAsync() { // see if the photo already contains geo coords var exif = new ExifInterface(_file.Path); if (!string.IsNullOrWhiteSpace(exif.GetAttribute(ExifInterface.TagGpsLatitude))) return; RequestCurrentLocation(); var location = await _locationTCS.Task; try { int num1Lat = (int)Math.Floor(location.Latitude); int num2Lat = (int)Math.Floor((location.Latitude - num1Lat) * 60); double num3Lat = (location.Latitude - ((double)num1Lat + ((double)num2Lat / 60))) * 3600000; int num1Lon = (int)Math.Floor(location.Longitude); int num2Lon = (int)Math.Floor((location.Longitude - num1Lon) * 60); double num3Lon = (location.Longitude - ((double)num1Lon + ((double)num2Lon / 60))) * 3600000; exif.SetAttribute(ExifInterface.TagGpsLatitude, num1Lat + "/1," + num2Lat + "/1," + num3Lat + "/1000"); exif.SetAttribute(ExifInterface.TagGpsLongitude, num1Lon + "/1," + num2Lon + "/1," + num3Lon + "/1000"); if (location.Latitude > 0) { exif.SetAttribute(ExifInterface.TagGpsLatitudeRef, "N"); } else { exif.SetAttribute(ExifInterface.TagGpsLatitudeRef, "S"); } if (location.Longitude > 0) { exif.SetAttribute(ExifInterface.TagGpsLongitudeRef, "E"); } else { exif.SetAttribute(ExifInterface.TagGpsLongitudeRef, "W"); } exif.SaveAttributes(); } catch (Java.IO.IOException) { // location will not be available on this image, but continue } }