Skip to content

Instantly share code, notes, and snippets.

@azhe403
Last active July 17, 2022 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azhe403/dca6df4cd2234e521900ccc3bcfd246d to your computer and use it in GitHub Desktop.
Save azhe403/dca6df4cd2234e521900ccc3bcfd246d to your computer and use it in GitHub Desktop.
Windows Get Location
private async void Button_Click(object sender, RoutedEventArgs e)
{
    var locator = new Windows.Devices.Geolocation.Geolocator();
    var location = await locator.GetGeopositionAsync();
    var position = location.Coordinate.Point.Position;
    var latlong = string.Format("lat:{0}, long:{1}", position.Latitude, position.Longitude);
    var result = MessageBox.Show(latlong);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment