A position on Earth (not including altitude), and an optional heading.
コード例 #1
0
 private void OnLocationChanged( GeoPosition location )
 {
     var evt = LocationChanged;
     if ( evt != null )
     {
         evt( this, new LocationChangedEventArgs( location ) );
     }
 }
コード例 #2
0
ファイル: GeoPosition.cs プロジェクト: accandme/pocketcampus
        /// <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 ) ) ) ) );
        }
コード例 #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 );
     }
 }
コード例 #4
0
 /// <summary>
 /// Creates a new LocationChangedEventArgs.
 /// </summary>
 public LocationChangedEventArgs(GeoPosition location)
 {
     Location = location;
 }
コード例 #5
0
 /// <summary>
 /// Creates a new LocationChangedEventArgs.
 /// </summary>
 public LocationChangedEventArgs( GeoPosition location )
 {
     Location = location;
 }
コード例 #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 );
 }