XLabs.Forms Geolocation does not work

EsritInesEsritInes MXMember ✭✭
edited October 2017 in Xamarin.Forms

I am tried to geolocalization with XLas.Forms but the code return null at first line. Must I do something to set up the geolocalization?

This is all I have to get the position:

    protected async Task<string> ObtenerLocalizacion()
    {
        var localizador = DependencyService.Get<IGeolocator>();

        string jsonPosicion = string.Empty;

        if (localizador.IsGeolocationEnabled)
        {
            if (!localizador.IsListening)
            {
                localizador.StartListening(1000, 1000);

                var posicion = await localizador.GetPositionAsync(10000, CancellationToken.None);

                jsonPosicion = JsonConvert.SerializeObject(posicion);
            }
        }

        return jsonPosicion;
    }
Sign In or Register to comment.