Created
February 24, 2014 14:41
-
-
Save guilhermecarvalhocarneiro/9189531 to your computer and use it in GitHub Desktop.
Evento Async para pegar as coordenadas atual do usuário
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 StartGeoLocation() | |
{ | |
try | |
{ | |
City city = new City(); | |
if (city.GetCurrencyCity() == null) | |
{ | |
//TODO Preciso verificar o load da localizacao | |
Geolocator geolocator = new Geolocator(); | |
geolocator.DesiredAccuracyInMeters = 50; | |
Geoposition geoposition = await geolocator.GetGeopositionAsync( | |
maximumAge: TimeSpan.FromMinutes(5), | |
timeout: TimeSpan.FromSeconds(10) | |
); | |
SetCurrentLocation(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude); | |
} | |
else | |
{ | |
SetCurrentLocation(city.GetCurrencyCity().latitude, city.GetCurrencyCity().longitude); | |
} | |
} | |
catch (Exception ErroStartLocation) | |
{ | |
System.Diagnostics.Debug.WriteLine("Error load"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment