Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hora Local: ServicioGelocalizacion
// Ejemplo adaptado de la documentación:
using Plugin.Geolocator;
using Plugin.Geolocator.Abstractions;
using System;
using System.Threading.Tasks;
namespace HoraLocal.Servicios
public static class ServicioGelocalizacion
public static async Task<Position> ObtenerUbicacionActual()
Position ubicacion = null;
var gps = CrossGeolocator.Current;
gps.DesiredAccuracy = 100;
if (!gps.IsGeolocationAvailable || !gps.IsGeolocationEnabled)
return null;
ubicacion = await gps.GetPositionAsync(TimeSpan.FromSeconds(20), null, true);
catch (Exception ex) { }
if (ubicacion == null)
return null;
return ubicacion;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.