async void AddMyCity_Clicked(object sender, EventArgs e) { try { viewModel.IsLoading = true; var request = new GeolocationRequest(GeolocationAccuracy.Default, TimeSpan.FromSeconds(10)); //var request = new GeolocationRequest(GeolocationAccuracy.Low, new TimeSpan(10)); Console.WriteLine("Middle"); CityByGeo response; String cityName; var location = await Geolocation.GetLocationAsync(request); Console.WriteLine("End"); if (location != null) { Console.WriteLine($"Latitude: {location.Latitude.ToString()}, Longitude: {location.Longitude}, Altitude: {location.Altitude}"); response = await viewModel.DataStore.requestMakerByCoords(location.Latitude.ToString(), location.Longitude.ToString()); cityName = response.results[0].components.city; //var placemarks = await Geocoding.GetPlacemarksAsync(location.Latitude, location.Longitude); //cityName = placemarks.FirstOrDefault().Locality; if (!Application.Current.Properties.ContainsKey(cityName)) { viewModel.AddMyCity(cityName); } else { viewModel.IsLoading = false; } } else { Notifier.ShortAlert("Не удалось определить местоположение, возможно нужно сменить гео-режим"); viewModel.IsLoading = false; } } catch (Exception ex) { Console.WriteLine("Exception == " + ex.ToString()); Notifier.LongAlert("Включите службу геолокации"); } }