private async void TextBlockPosition_Tapped(object sender, TappedRoutedEventArgs e) { var bt = sender as Control; if (bt != null) { bt.IsEnabled = false; } GPScoords gps = GPScoords.GetInstance(); try { Geolocator geolocator = new Geolocator(); Geoposition position = await geolocator.GetGeopositionAsync(); gps.Lat = position.Coordinate.Point.Position.Latitude; gps.Lon = position.Coordinate.Point.Position.Longitude; } catch { MessageDialog md = new MessageDialog("Проверьте, включена ли геолокация."); await md.ShowAsync(); } if (gps.Lat != -1 && gps.Lon != -1) { BasicGeoposition geoposition = CreateBasicGeoposition(gps.Lat, gps.Lon); ShowOnMapPosition(geoposition); } if (bt != null) { bt.IsEnabled = true; } }
public static GPScoords GetInstance() { if (_uniqueGPS == null) { _uniqueGPS = new GPScoords(); } return(_uniqueGPS); }