Ejemplo n.º 1
0
        public async Task StartListeningLocation()
        {
            await AppGeolocator.StartListeningAsync(MyGeoFlag, 1000);//minDistance will take priority

            AppGeolocator.Current.PositionChanged += PositionChanged;
            AppGeolocator.Current.PositionError   += PositionError;


            try
            {   //Starting Position
                var positionStart = await Task.Run(() => AppGeolocator.Current.GetPositionAsync(TimeSpan.FromMilliseconds(50), null, false).Result);

                PositionChanged(this, new PositionEventArgs(positionStart));
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unable to get location: " + ex);
            }
        }
Ejemplo n.º 2
0
        public async Task StartListeningLocation()
        {
            if (CheckGeoPermissions(true) == false)
            {
                AskForPermissions();
                return;
            }

            await AppGeolocator.StartListeningAsync(MyGeoFlag, 1000);//minDistance will take priority

            LocFlag = LocationFlag.Start;
            AppGeolocator.Current.PositionChanged += PositionChanged;
            AppGeolocator.Current.PositionError   += PositionError;

            try
            {   //Starting Position
                var positionStart = await Task.Run(() => AppGeolocator.Current.GetPositionAsync(TimeSpan.FromMilliseconds(50), null, false).Result);

                PositionChanged(this, new Plugin.Geolocator.Abstractions.PositionEventArgs(positionStart));
            }
            catch (Exception ex) {
                Debug.WriteLine("Unable to get location: " + ex);
            }
        }