-
-
Save mesadhan/ce1fbe8248dc36cadb03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private async void Button_Click(object sender, RoutedEventArgs e) | |
| { | |
| Geolocator geolocator = new Geolocator(); | |
| geolocator.DesiredAccuracyInMeters = 50; | |
| try | |
| { | |
| Geoposition geoposition = await geolocator.GetGeopositionAsync( | |
| maximumAge: TimeSpan.FromMinutes(5), | |
| timeout: TimeSpan.FromSeconds(10) | |
| ); | |
| //With this 2 lines of code, the app is able to write on a Text Label the Latitude and the Longitude, given by {{Icode|geoposition}} | |
| geolocation.Text = "GPS:"+geoposition.Coordinate.Latitude.ToString("0.00")+", "+geoposition.Coordinate.Longitude.ToString("0.00"); | |
| } | |
| //If an error is catch 2 are the main causes: the first is that you forgot to include ID_CAP_LOCATION in your app manifest. | |
| //The second is that the user doesn't turned on the Location Services | |
| catch (Exception ex) | |
| { | |
| //exception | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment