Last active
December 30, 2015 18:29
-
-
Save zoint/7867812 to your computer and use it in GitHub Desktop.
Basic position changed event handler
This file contains 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 PositionChangedHandler(Geolocator sender, PositionChangedEventArgs args) | |
{ | |
if (args.Position == null || args.Position.Coordinate == null) return; | |
//save updated coordinates to a property on the class | |
//can do whatever we want with position, all I need are the coordinates | |
Position = args.Position.Coordinate; | |
//stop the tracking once we have our desired accuracy in meters | |
if (args.Position.Coordinate.Accuracy < 500) | |
{ | |
// this implicitly stops the tracking operation | |
_geolocator.PositionChanged -= PositionChangedHandler; | |
//could raise an event here to let the UI thread know we have a position | |
//of the desired accuracy at this point. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment