public async Task IniciaGPS() { Ocupado = true; var plataforma = DependencyService.Get <IGeo>(); if (plataforma != null) { Geo g = new Geo(); plataforma.LatLonUpd = delegate(Geo gtmp) { Posicion = gtmp; }; plataforma.GetLatLon(); } Ocupado = false; }
public static double GetDistance(Geo p1, Geo p2) { double distance = 0; try { double Lat = (p2.latitude - p1.latitude) * (Math.PI / 180); double Lon = (p2.longitud - p1.longitud) * (Math.PI / 180); double a = Math.Sin(Lat / 2) * Math.Sin(Lat / 2) + Math.Cos(p1.latitude * (Math.PI / 180)) * Math.Cos(p2.latitude * (Math.PI / 180)) * Math.Sin(Lon / 2) * Math.Sin(Lon / 2); double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); distance = EarthRadius * c; } catch { } return(distance * 1000); }