Niyo

getLocation

Jan 19th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1.     /// <summary>
  2.         /// Get actual Position from GPS/Wifi/gsm
  3.         /// </summary>
  4.         /// <returns></returns>
  5.         private async Task<Geoposition> getLocation(int maxAgeInMinutes = 5, int timeOutinSeconds = 10)
  6.         {
  7.             Geolocator geolocator = new Geolocator();
  8.  
  9.             Geoposition geoposition = null;
  10.  
  11.             if (geolocator.LocationStatus != PositionStatus.Disabled) // Check if we can access the LocationService
  12.             {
  13.                 geoposition = await geolocator.GetGeopositionAsync(
  14.                 maximumAge: TimeSpan.FromMinutes(maxAgeInMinutes),
  15.                 timeout: TimeSpan.FromSeconds(timeOutinSeconds)
  16.                 );
  17.             }
  18.  
  19.             return geoposition;
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment