Tag: cllocationmanager

iOS CoreLocation检查CLLocation时间戳以使用它

你如何检查一个CLLocation对象,并决定是否要使用它,或放弃结果,并得到一个新的位置更新呢? 我看到CLLocation上的timestamp属性,但我不知道如何将它与当前时间进行比较。 另外,在比较了时间之后,我们可以发现秒之间的差异,那么使用该CLLocation对象的区别是什么? 什么是一个好的门槛。 谢谢!

在NSOperation中使用委托

我想在NSOperation使用CLLocationManager 。 作为这个的一部分,我需要startUpdatingLocation的能力,然后等待,直到收到一个CLLocation完成操作。 目前我做了以下工作,但是这个委托方法似乎从来没有被调用过。 请有人build议是什么问题? – (void)main { @autoreleasepool { if (self.isCancelled) return; // Record the fact we have not found the location yet shouldKeepLooking = YES; // Setup the location manager NSLog(@"Setting up location manager."); CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; while (shouldKeepLooking) { if (self.isCancelled) […]

按照用户所在的方向旋转GMSMarker

我有要求就像我目前的位置一个视图将显示。 它会旋转,如果设备是旋转或位置会改变。我研究了很多,但得到了所有的代码有一个固定的位置或angular度在某些位置,但我没有确定位置。 任何人都可以驾驶我正确的方向。 我也使用GMSMarker的旋转属性,但它不工作。 – (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { if (newHeading.headingAccuracy < 0){ NSLog(@"heading accuracy < 0"); return; } // Convert Degree to Radian and move the needle float oldRad = (- manager.heading.trueHeading) * M_PI / 180.0f; float newRad = (- newHeading.trueHeading) * M_PI / 180.0f; // Compass animation CABasicAnimation *theAnimation; theAnimation = [CABasicAnimation […]

didEnterRegion调用较大的半径(iOS)

我想要非常精确地调用didEnterRegion,但是我无法做到这一点。 以下是我所做的:我使用了distanceFilter和desiredAccuracy(根据Apple的最精确的GPS设置)的最佳值,并且具有目的地CLCircularRegion(CLRegion的子类)。 self.locationManager.distanceFilter = kCLLocationAccuracyBestForNavigation; self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; @property (nonatomic, strong) CLCircularRegion *Destination; self.Destination = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(43.907691, -69.963158) radius:5 identifier:@"Destination"]; [self.locationManager startMonitoringForRegion:self.Destination]; 问题是当我离这个目的地150米远时,didEnterRegion被调用。 也在类似的距离离开didExitRegion被调用。 我想要在5米以外,而不是150米以外的地方调用didEnter和didExit区域,因为我已经指定了CLCircularRegion的启动。 有没有人有办法解决吗? 精度是我需要的,150米而不是5米对我来说太不准确了。 谢谢吨 – (我用iPhone 4S来testing)

区域监视当前位置不会退出时通知

我试图testing区域监控,因为我得到这样的当前位置: – (void)startLocationTracking { CLLocationManager *locationManager = [[CLLocationManager alloc] init]; // Start location manager if ([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) { locationManager = [LocationTracker sharedLocationManager]; locationManager.delegate = self; [locationManager startMonitoringSignificantLocationChanges]; } } 跟踪像这样的区域监视的第一个位置: -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:manager.location.coordinate radius:300 identifier:@"first location initializer"]; […]

通过静默推送通知startUpdatingLocationManager

我正在创build需要在特定时间在后台唤醒的应用程序。 我努力了 : UILocalNotification:但我不想使用UILocalNotification,因为它需要用户交互来点击通知,并且只有应用程序会唤醒并启动位置pipe理器。 我也用过[locationManager startUpdatingLocation]; 启用背景模式位置更新,这是工作,但它会占用大量的电池。 因此,使用新的iOS 7functionSilent pushNotification和Silent pushNotification didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:方法我需要在后台启动位置pipe理器, -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{ NSLog(@"Receive RemoteNotification in fetchCompletionHandler with UserInfo:%@",userInfo); application.applicationIconBadgeNumber=0; __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ [self.locationManager startUpdatingLocation]; [application endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; }]; } 无声推送通知工作正常, PushNotification的有效载荷: {"aps" : {"content-available" : 1},"SilentPushId" : "07"} 但这不会启动位置经理,请有人帮助我。 编辑: 如果这是不可能的,请给我一些build议。

计算累计海拔增益给我更奇怪的结果

我有使用CoreLocation和跟踪用户移动的应用程序。 当用户正在行走或驾驶时,我将每个坐标保存到本地数据库(lat / lng / alt),以便根据保存的坐标绘制路线。 前几天我已经添加累积海拔增益 ,我用这个代码 didLocationUpdate: – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { netElevationGain += MAX(0, oldLocation.altitude – newLocation.altitude); } 但是有些事情是错的。 我开始申请,开始步行,走了几英里,我得到了networkingnetElevationGain差不多500米。 没有办法,这是正确的。 这是每个点保存在数据库中的netElevation列表: 0,41,43,44,47,52,55,62,73,80,91,100,114,140,146,153,159,180,199,208,228,240,259,275,320,329,349,359,366,375,381,392,408,419,428,437,446,449,462,469,478,486 海拔高度 0.000000,181.678055,181.891495,182.786850,179.315399,177.035721,182.636307,181.259399,178.653015,192.552551,185.398819,182.693436,181.369766,154.306747,157.031693,159.748871,185.080856,198.080673,176.473877,178.646851,175.784424,178.184128,181.237488,188.956894,177.713181,193.673019,188.470184,182.749054,181.966507,181.547592,191.638657,198.713989,188.582977,197.977921,203.184540,205.108856,198.304123 要显示增益,我使用简单的select max(gain) from table where … UPDATE 现在我得到更差的价值(按降序): Alt键: 200.334869,200.594666,196.293945,195.240234,191.800446,192.622375,179.951385,179.185577,179.681122,177.843719,183.459595,174.170502,0.000000 获得: 307,301,294,285,275,269,252,246,234,227,217,202,0

在Mapview Xcode中更新位置

在我目前的项目。 我需要每50 meter用户移动用户的位置。 所以基本上每打开一个50 meter变化后,我需要在Objective c调用Web服务的用户位置。 另外我希望当应用程序处于后台状态时运行相同的进程。 提前致谢

iOS LocationManager没有更新位置(Titanium Appcelerator模块)

我已经使Appceleratortitanium模块获取设备的旋转和位置。 来源可以在GitHub上find 。 问题是它只提取一个caching的位置,但设备运动数据正常并且正在刷新。 我不使用委托,我拉我的titanium的JavaScript代码中的数据。 如果我在模拟器中设置“城市运行” – >debugging – >位置没有任何反应。 相同的caching位置正在返回。 拉的位置是可以的,因为我尝试使用本地应用程序至极: textView.text = [NSString stringWithFormat:@"%f %f\n%@", locationManager.location.coordinate.longitude, locationManager.location.coordinate.latitude, textView.text]; 它正在模拟器和设备上工作。 但是,您可以在GitHub上看到相同的代码不能用作Titanium模块。 有任何想法吗? 编辑: 我在看GeolocationModule SRC ,我没有看到什么特别的。 正如我所说,我的模块中的代码必须工作,因为它在本地应用程序中工作。 “唯一”的问题是,它不是更新位置,它总是返回我caching的位置。

iOS更新位置,即使应用程序终止

我试图更新用户的位置,即使应用程序被终止。 我添加了地图和背景模式 – >位置更新到我的.plist,我设置了一个本地通知,当位置更新时将触发。 但它从来没有被解雇。 我在AppDelegat.h中有这个: @interface AppDelegate : UIResponder <CLLocationManagerDelegate>{ CLLocationManager *locationManager; } 和AppDelegate.m中 – (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager requestAlwaysAuthorization]; [locationManager startMonitoringSignificantLocationChanges]; } – (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { UILocalNotification *notification = [[UILocalNotification alloc]init]; notification.repeatInterval = NSDayCalendarUnit; [notification setAlertBody:@"Location update!"]; […]