Forum Xamarin.Forms

GeoLocation unable to get location but Google Maps is

Steve1000Steve1000 Member ✭✭✭
edited January 8 in Xamarin.Forms

Hi,

I'm using the following code

location = await Geolocation.GetLastKnownLocationAsync();
var request = new GeolocationRequest(GeolocationAccuracy.Medium); // for the current location


if (location == null)
{
   location = await Geolocation.GetLocationAsync(request);
}

For a couple of users, this seemed to hang on GetLocationAsync.

However, when they opened up Google Maps and then ran the app with this code it seemed to all work OK - I presume because the GetLastKnownLocation was populated by the Google Maps signal.

Question is how would google maps be able to get the location but the Xamarin wasn't? Is it due to the Accuracy setting?

Tagged:

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Have you set a timeout in your code?

    Besides, could you please post the full error log when this problem occured?


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • Steve1000Steve1000 Member ✭✭✭

    Hi no timeout - just the code put above. I haven't got an error code as I can't reproduce the scenario myself unless i turn off GPS in the iOS Simulator

  • jezhjezh Member, Xamarin Team Xamurai

    Have you tested on android devices?

Sign In or Register to comment.