GetGeopositionAsync() never giving results.


  • I have been struggling to figure out why when using the GetGeopositionAsync() method, does it seem to only work sporadically. Sometimes it will work great and be super fast, other times it will just never return anything, no error and the timeout doesn't seem to work either, it just never completes.

     Geolocator geolocator = new Geolocator();
                    geolocator.DesiredAccuracyInMeters = 200;
                    geolocator.DesiredAccuracy = PositionAccuracy.Default;
    Geoposition geoposition = await geolocator.GetGeopositionAsync(maximumAge: TimeSpan.FromMinutes(15), timeout: TimeSpan.FromSeconds(10));
    The code is ran from the UI thread (although running from a BackgroundWorker did not seem to make a difference). I am at a complete loss. Im thinking I will just go back to use the

    GeoCoordinateWatcher, at least that works. Any help will be greatly appreciated. Thank you!

    Thursday, February 21, 2013 11:05 PM

All replies

  • Have you tweated with some of the properties to change the threshold to be smaller?

    what about subscribing to some of the events it has like status changed and position changed rather than calling with the way your are doing right now?


    Friday, February 22, 2013 12:11 AM
  • Yes I have adjusted the threshold and other settings multiple times with no luck. I am guessing I will need to subscribe to the staus changed event. All the Windows Phone 8 docs say to use the async method as I have it for one shot locations. Just seems silly it won't return anything at random times for no apparent reason. I still don't quite understand how to stop the async call once/if I do get a status changed event, I'll know its done but what then?
    Friday, February 22, 2013 3:43 AM
  • Same case for us. Just wonder why, can't be catched in try block and just said some object not instantiate.
    Thursday, March 21, 2013 1:53 PM
  • I'm seeing the same behavior. However, once it fails - the 2nd and subsequent times are more likely to work. I'm wondering about trying a call to this before any UI shows...just to "prime" it with one failure...A hack to be sure, but I really need this work.

    Steve Daum

    Saturday, May 11, 2013 3:09 PM
  • I have the same problem. After a lot of debugging and experimenting I finally had to give up on GetGeopositionAsync() and are now using the tracking APIs to just get one set of coordinates. I.e. I do it the same way as I did in the Windows Phone 7.x version of the app although the APIs are a bit different.

    Really a shame, but GetGeopositionAsync() seems to be fundamentally unreliable. However, it seems to work fine when used in a scheduled task once every half hour, but I think that is due to that scheduled tasks are feed cached location values and therefore it can return almost immediately.

    Tuesday, May 14, 2013 10:36 AM
  • I've been having the same issue and I think I found a solution.

    I think the problem is that if a location request fails then the async method goes into a deadlock. So if you don't have internet, no gps signal, or even you closed the app before a response comes back, then the next time you request a location it never returns a response.

    I haven't tested it that much but I haven't had the issue since I tried this. Let me know if your miles vary. 

                    Geolocator geolocator = new Geolocator();
                    geolocator.DesiredAccuracy = PositionAccuracy.Default;
                    IAsyncOperation<Geoposition> locationTask = null;
                        locationTask = geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(15));
                        Geoposition position = await locationTask;
                        if (locationTask != null)
                            if (locationTask.Status == AsyncStatus.Started)



    • Edited by OrenGold Thursday, July 4, 2013 5:56 AM edit
    • Proposed as answer by Ricky_Brundritt Thursday, September 18, 2014 11:30 AM
    Thursday, July 4, 2013 5:54 AM
  • This worked for me. And it is still working after a day. I don't know when it gives up since the GetGeoPositionAsync() method is very unpredictable! Thank you OrenGold!
    • Edited by akshayar640 Wednesday, July 24, 2013 6:59 AM Formatting was not right.
    Wednesday, July 24, 2013 6:58 AM
  • Just try 

    await geolocator.GetGeopositionAsync();

    without parameters. It worked for me.

    Tiziano Cacioppolini

    Wednesday, July 24, 2013 9:17 AM
  • This weird behaviour happens when the GetGeopositionAsync() is called while the geolocator is in NotInitialized" state. Geolocator is only initialized either when it is subscribed to positionchanged event or if a GetGeopositionAsync() method is called already.

    Inorder to make it work, you just have to subscribe the geolocator to a positionchanged event before calling the GetGeopositionAsync() call.

    Wednesday, November 6, 2013 5:21 PM
  • After some looking for answers to this, it became apparent that there was something wrong with the new class because it should have worked right out of the box as it was a replacement of a deprecated library. Also, the call works on an actual device with no problems. So what is the difference? The emulator was the difference.

    The emulator doesn't "default" to Seattle, WA anymore. The location configuration does, but you actually have to SET the point on the map. Once set, voila! GetGeopositionAsync works just fine, it is the emulator that was not set to a default as it had been in the past and REQUIRES configuring.

    Hope this helps everyone!

    T.J. Mullen

    Thomas Mullen

    Sunday, July 27, 2014 3:31 PM
  • Hello everyone,

    My question is can I setup Geolocator in the App.xaml.cs file or is there a better place?

    My finding

    Here it is feb. 12, 2016 almost 3 years since the first post and the same problem still exists! I subscribed to the events and consider the documentation is wrong, as well as the example I was following. In the code below I had added two more _geoLoc = new Geolocator(); statements "Page_Loaded", and in the "case GeolocationAccessStatus.Allowed:". I commd out the these two and I found I was getting "Initializing" and then the event fires.

    So, on "Allowed" add the events and "_geoLoc.LocationStatus" gets you "Initializing" your good to go.

    Geo should be as simple as checking a box and you should be good to go - or just ask for a location out of thin air. So make this a load or constructor placement. Every phone tablet etc has location aware so why so many hurdles.

    I later added another button used the GetGeopositionAsync and it fires on the ui thread immediately.

    using System;
    using Windows.UI.Xaml.Controls;
    using Windows.Devices.Geolocation;
    namespace hnh_gpsGambits.Pages
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class WelcomePage : Page
            public int Ozwald1 = 0;
            public Geolocator _geoLoc = new Geolocator();
            public Geoposition _CurrentGeoItem;
            public WelcomePage()
            private void Page_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
                // txt_HNH.Text = "welcome to HNH";
                //_geoLoc = new Geolocator();
            private async void btnFindCoordinate_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
                var accessStatus = await Geolocator.RequestAccessAsync();
                switch (accessStatus)
                    case GeolocationAccessStatus.Denied:
                        btnFindCoordinate.Content = "Denied";
                    case GeolocationAccessStatus.Unspecified:
                        btnFindCoordinate.Content = "Unspecified";
                    case GeolocationAccessStatus.Allowed:
                        _geoLoc.PositionChanged += _geoLoc_PositionChanged;
                        _geoLoc.StatusChanged += _geoLoc_StatusChanged;
                        //_geoLoc = new Geolocator();
                        switch (_geoLoc.LocationStatus)
                            case PositionStatus.NotInitialized:
                                btnFindCoordinate.Content = "NotInitialized";
                            case PositionStatus.Disabled:
                                btnFindCoordinate.Content = "Disabled";
                            case PositionStatus.Initializing:
                                btnFindCoordinate.Content = "Initializing";
                            case PositionStatus.NoData:
                                btnFindCoordinate.Content = "NoData";
                            case PositionStatus.NotAvailable:
                                btnFindCoordinate.Content = "NotAvailable";
            private void _geoLoc_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
                //throw new NotImplementedException();
            private void _geoLoc_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
                //throw new NotImplementedException();
                //tbkLatitude.Text= args.Position.Coordinate.Latitude.ToString();
                //tbkLongitude.Text = args.Position.Coordinate.Longitude.ToString();
            private async void btnFindCoordinate2_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
                // Carry out the operation
                Geoposition pos = await _geoLoc.GetGeopositionAsync();
                tbkLatitude.Text = pos.Coordinate.Latitude.ToString();
                tbkLongitude.Text = pos.Coordinate.Longitude.ToString();


    Friday, February 12, 2016 9:00 PM