public GeofenceLocation(GeofenceLocation loc) { Latitude = loc.Latitude; Longitude = loc.Longitude; Date = loc.Date; Accuracy = loc.Accuracy; }
void SetLastKnownLocation(CLLocation location) { if (location != null) { if (lastKnownGeofenceLocation == null) { lastKnownGeofenceLocation = new GeofenceLocation(); } lastKnownGeofenceLocation.Latitude = location.Coordinate.Latitude; lastKnownGeofenceLocation.Longitude = location.Coordinate.Longitude; lastKnownGeofenceLocation.Accuracy = location.HorizontalAccuracy; DateTime referenceDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0)); lastKnownGeofenceLocation.Date = referenceDate.AddSeconds(location.Timestamp.SecondsSinceReferenceDate); CrossGeofence.GeofenceListener.OnLocationChanged(lastKnownGeofenceLocation); } }
internal void SetLastKnownLocation(Android.Locations.Location location) { if (location != null) { GeofenceLocation eventLoc; lock (Lock) { if (mLastKnownGeofenceLocation == null) { mLastKnownGeofenceLocation = new GeofenceLocation(); } mLastKnownGeofenceLocation.Latitude = location.Latitude; mLastKnownGeofenceLocation.Longitude = location.Longitude; double seconds = location.Time / 1000; mLastKnownGeofenceLocation.Date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local).AddSeconds(seconds); mLastKnownGeofenceLocation.Accuracy = location.Accuracy; eventLoc = new GeofenceLocation(mLastKnownGeofenceLocation); } CrossGeofence.GeofenceListener.OnLocationChanged(eventLoc); } System.Diagnostics.Debug.WriteLine("Setting last location"); }