Пример #1
0
 /// <summary>
 ///     두지점 사이의 거리 반환
 ///     http://blogs.msdn.com/b/dragoman/archive/2010/09/29/wp7-code-distance-computations-with-the-geolocation-api.aspx
 /// </summary>
 /// <param name="in"></param>
 /// <param name="here"></param>
 /// <param name="there"></param>
 /// <returns></returns>
 public static double Between(this DistanceIn @in, GeocoordinatePCL here, GeocoordinatePCL there)
 {
     int r = (@in == DistanceIn.Miles) ? 3960 : 6371;
     double dLat = (there.Latitude - here.Latitude).ToRadian();
     var dLon = (there.Longitude - here.Longitude).ToRadian();
     double a = Math.Sin(dLat/2)*Math.Sin(dLat/2) +
                Math.Cos(here.Latitude.ToRadian())*Math.Cos(there.Latitude.ToRadian())*
                Math.Sin(dLon/2)*Math.Sin(dLon/2);
     double c = 2*Math.Asin(Math.Min(1, Math.Sqrt(a)));
     double d = r*c;
     return d;
 }
 /// <summary>
 /// 위치 반환 - 비동기로 만들면 스레드 사라짐
 /// </summary>
 /// <returns></returns>
 public override GeocoordinatePCL GetGeocoordinate()
 {
     GeocoordinatePCL returnValue = null;
     if (_geoposition == null)
     {
         returnValue = _defaultGeoPosition;
     }
     else
     {
         returnValue = new GeocoordinatePCL
         {
             Accuracy = _geoposition.Coordinate.Accuracy,
             Altitude = _geoposition.Coordinate.Point.Position.Altitude,
             AltitudeAccuracy = _geoposition.Coordinate.AltitudeAccuracy,
             Heading = _geoposition.Coordinate.Heading,
             Latitude = _geoposition.Coordinate.Point.Position.Latitude,
             Longitude = _geoposition.Coordinate.Point.Position.Longitude,
             Speed = _geoposition.Coordinate.Speed,
             Timestamp = _geoposition.Coordinate.Timestamp
         };
     }
     return returnValue;
 }
        public override void Init()
        {
            _geolocator = new Geolocator();
            //_geolocator.MovementThreshold = 1;
            //_geolocator.ReportInterval = 1;
            _geolocator.PositionChanged += geolocator_PositionChanged;

            _defaultGeoPosition = new GeocoordinatePCL
                {
                    Accuracy = 1.0,
                    Altitude = 13,
                    Latitude = 37.566535,
                    Longitude = 126.977969,
                    Timestamp = DateTime.Now
                };
            _defaultCivicAddress = new CivicAddressPCL 
                {
                    City = "Seoul",
                    Country = "ko-KR",
                    PostalCode = "",
                    State = "",
                    Timestamp = DateTimeOffset.Now
                };
        }