A position on Earth (not including altitude), and an optional heading.
Exemplo n.º 1
0
 private void OnLocationChanged( GeoPosition location )
 {
     var evt = LocationChanged;
     if ( evt != null )
     {
         evt( this, new LocationChangedEventArgs( location ) );
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Computes the distance to another GeoPosition.
        /// </summary>
        public double DistanceTo( GeoPosition other )
        {
            double lat1 = this.Latitude * RadianCoeff,
                   lat2 = other.Latitude * RadianCoeff,
                   lon1 = this.Longitude * RadianCoeff,
                   lon2 = other.Longitude * RadianCoeff;

            return EarthRadiusInKilometers * 2 * Math.Asin( Math.Min( 1, Math.Sqrt( ( Math.Pow( Math.Sin( ( lat2 - lat1 ) / 2.0 ), 2.0 ) + Math.Cos( lat1 ) * Math.Cos( lat2 ) * Math.Pow( Math.Sin( ( lon2 - lon1 ) / 2.0 ), 2.0 ) ) ) ) );
        }
Exemplo n.º 3
0
 /// <summary>
 /// Asynchronously gets the user's location.
 /// </summary>
 public async Task<Tuple<GeoPosition, GeoLocationStatus>> GetLocationAsync()
 {
     try
     {
         var geoPosition = await _locator.GetGeopositionAsync();
         _lastKnownLocation = PositionFromCoordinate( geoPosition.Coordinate );
         return Tuple.Create( _lastKnownLocation, GeoLocationStatus.Success );
     }
     catch
     {
         return Tuple.Create( (GeoPosition) null, GeoLocationStatus.Error );
     }
 }
 /// <summary>
 /// Creates a new LocationChangedEventArgs.
 /// </summary>
 public LocationChangedEventArgs(GeoPosition location)
 {
     Location = location;
 }
 /// <summary>
 /// Creates a new LocationChangedEventArgs.
 /// </summary>
 public LocationChangedEventArgs( GeoPosition location )
 {
     Location = location;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Occurs when the user's position changes.
 /// </summary>
 private void Locator_PositionChanged( Geolocator sender, PositionChangedEventArgs args )
 {
     _lastKnownLocation = PositionFromCoordinate( args.Position.Coordinate );
     OnLocationChanged( _lastKnownLocation );
 }