void ILocationListener.OnLocationChanged(AndroidLocation location)
        {
            if (location.Accuracy <= desiredAccuracy)
            {
                if (wasRaised)
                {
                    return;
                }

                wasRaised = true;

                LocationHandler?.Invoke(location);
                return;
            }

            lock (locationSync)
            {
                if (Geolocation.IsBetterLocation(location, BestLocation))
                {
                    BestLocation = location;
                }
            }
        }
Beispiel #2
0
        public async Task Geolocalizar( )
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Latitude = String.Format("{0}", location.Latitude);
                    Longitud = String.Format("{0}", location.Longitude);
                    Altitude = String.Format("{0:0.00}", location.Altitude);
                }
            }
            catch   {
                Latitude = ".";
                Longitud = ".";
                Altitude = ".";
            }
            finally {
                Latitude = "-";
                Longitud = "-";
                Altitude = "-";
            }
        }
Beispiel #3
0
 public static Task <Location> GetLocation()
 {
     return(Task.Run(() => Geolocation.GetLocationAsync().GetAwaiter().GetResult()));
 }