/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Helpers/LocationHelpers.cs
39 строк
981 B
Yair
Code Quality: Updated license header
31 дек 2024, 05:03
31 дек 2024, 05:03
8436c6d
Код
Авторство
О чём код?
// Copyright(c) Files Community // Licensed under the MIT License. using Windows.Devices.Geolocation; using Windows.Services.Maps; namespace Files.App.Helpers { public static class LocationHelpers { public static async Task<string> GetAddressFromCoordinatesAsync(double? Lat, double? Lon) { if (!Lat.HasValue || !Lon.HasValue) return null; if (string.IsNullOrEmpty(MapService.ServiceToken)) { try { MapService.ServiceToken = Constants.AutomatedWorkflowInjectionKeys.BingMapsSecret; } catch (Exception) { return null; } } BasicGeoposition location = new BasicGeoposition(); location.Latitude = Lat.Value; location.Longitude = Lon.Value; Geopoint pointToReverseGeocode = new Geopoint(location); // Reverse geocode the specified geographic location. var result = await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode); return result?.Locations?.FirstOrDefault()?.DisplayName; } } }