Forum Xamarin.Forms

Plugin.Geolocator not returning Latitude/Longitude and no error

JassimRahmaJassimRahma USMember ✭✭✭✭

Hi,

I am trying to use the Plugin.Geolocator to get the user's current location.

I used below code and it's launching the app with no errors but I am not getting any value for Latitude or Longitude... it's just blank and no error..

This problem is for both iOS simulator and Android Emulator.

protected async override void OnAppearing()
{
    base.OnAppearing();

    var locator = CrossGeolocator.Current;

    locator.DesiredAccuracy = 50;

    var position = await locator.GetPositionAsync();

    LabelLatitude.Text = position.Latitude.ToString();
    LabelLongitude.Text = position.Longitude.ToString();
}

How to fix this please..

Thanks,
Jassim

Answers

  • JohnHardmanJohnHardman GBUniversity mod

    @JassimRahma - Test on a physical device unless using a simulator/emulator that is expected to provide position information.

  • Liêm_NguyễnLiêm_Nguyễn USMember ✭✭✭✭

    Try to test on real devices and try out door to make sure the best GPS signal. Don't forget allow LOCATION permission

  • Steve1000Steve1000 Member ✭✭

    Hi i'm having similar issues did you manage to solve this?

    @NTL_Dev said:
    Try to test on real devices and try out door to make sure the best GPS signal. Don't forget allow LOCATION permission

    How to allow Location permissions? i don't even get prompted to allow / disallow Location permissions.

  • Liêm_NguyễnLiêm_Nguyễn USMember ✭✭✭✭

    @Steve1000 said:

    Hi i'm having similar issues did you manage to solve this?

    @NTL_Dev said:
    Try to test on real devices and try out door to make sure the best GPS signal. Don't forget allow LOCATION permission

    How to allow Location permissions? i don't even get prompted to allow / disallow Location permissions.

    Watch OutPut Windows to find error!
    And read again document

  • abhay27abhay27 Member ✭✭

    Give permission on Android.Manifest

  • BhautikBhautik Member ✭✭✭

    Facing the same error.

    var locator = CrossGeolocator.Current;
    var _position = await locator.GetPositionAsync();

    After the GetPositionAsync method calls its never return.

  • JassimRahmaJassimRahma USMember ✭✭✭✭

    I started using Xamarin Essentials .. it's excellent...

Sign In or Register to comment.