Tag: core location

Geofencing iOS 6

我正在创build一个应用程序,告诉用户他们是否在目的地附近。 我正在计算currentLocation和目的地之间的距离。 我正在做didUpdateLocations里面的didUpdateLocations 。 它正在工作,但我已经看到,有一些方法可以处理,而不需要做任何的math计算。 我正在注册CLLocationManager的区域; 但是,似乎didExitRegion和didEnterRegion方法没有被调用。 以下是我注册地区的部分代码: – (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { [self.locationManager startUpdatingLocation]; [self.mySearchBar resignFirstResponder]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; self.distToRemind = 0; [worldMap removeAnnotations:[worldMap annotations]]; NSLog(@"executou de primeira"); CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:[self.mySearchBar text] completionHandler:^(NSArray *placemarks, NSError *error) { CLPlacemark *placemark = [placemarks lastObject]; //test //DefaultAnnotation *annot = [[DefaultAnnotation alloc] initWithCoordinate:placemark.location.coordinate andTitle:@""]; […]

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

我试图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"]; […]

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

我有使用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

将CLPlacemark扩展为EXC BAD ACCESS

虽然在这里发现了一个类似的问题,但它并没有提供答案,至less不是针对一般问题。 我的问题是:由于CoreLocation地理编码速度有限,而且我正在开发应用程序的(web-)服务提供了自己的后备地址parsing服务,所以我想使用此自定义地理编码服务以防万一达到Apple的速率限制。 此外,我觉得避免自定义数据types对于由此自定义REST API返回的结果是CLPlacemark的,因此希望使用返回的数据来生成CLPlacemark 。 但是,文档指出CLPlacemark属性(如location, locality, administrativeArea等)是read-only 。 因此,我创build了一个CLPlacemark的子类,将需要的属性合成到我可以访问的私有variables上,即: // interface: (.h) @interface CustomPlacemark : CLPlacemark – (nonnull id)initWithLocation: (nonnull CLLocation *)location locality: (nullable NSString *)locality administrativeArea: (nullable NSString *)adminArea country: (nullable NSString *)country; @end // implementation (.m) @implementation CustomPlacemark @synthesize location = _location; @synthesize locality = _locality; @synthesize country = _country; @synthesize administrativeArea […]

CLLocationManager委托方法没有被调用

我正在使用CLLocationManager类。 我有一个简单的类捕获位置的方法 +(void)captureLocation{ mLocationManager = [[CLLocationManager alloc]init]; mLocationManager.delegate = (id<CLLocationManagerDelegate>)self; mLocationManager.desiredAccuracy = kCLLocationAccuracyBest; [mLocationManager startUpdatingLocation]; } 我也有CLLocationManager的委托方法 – (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { } – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { } 现在我试图在我的viewDidLoad调用这个方法 – (void)viewDidLoad { [super viewDidLoad]; [myclass captureLocation]; } 该方法正在调用,但委托方法没有被调用。 我也有其他的类方法,如果我再次尝试调用方法captureLocation方法被调用,但不调用委托方法。 这是另一个类的方法 +(void)initialize{ [self captureLocation]; } 请帮我找出为什么委托方法没有被调用,因为我是这个领域的新手。 提前致谢。

核心位置委托方法没有在iOS 8.3 Xcode 6.3.1中调用

我试图在Xcode 6.3.1中使用Core Location Framework获取用户的当前位置,我做了以下事情: 目标 – > 常规 – > 链接框架和库下添加核心位置框架 我的ViewController.h文件如下所示, #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface ViewController : UIViewController<CLLocationManagerDelegate> @property (weak, nonatomic) IBOutlet UILabel *lblLatitude; @property (weak, nonatomic) IBOutlet UILabel *lblLongitude; @property (weak, nonatomic) IBOutlet UILabel *lblAddress; @property (strong, nonatomic) CLLocationManager *locationManager; @end 我的ViewController.m文件如下所示, – (void)viewDidLoad { [super viewDidLoad]; self.locationManager = [[CLLocationManager alloc] init]; […]

用户在运动中的距离

我正在编写一个应用程序,在用户走动时显示用户与固定点的距离(即每次用户移动时,显示用户到点的距离的标签都会更新)。 我使用了一个CLLocationManager,代码如下: – (void)viewDidLoad { locationManager=[[CLLocationManager alloc]init]; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; } -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocationDistance meters = [newLocation distanceFromLocation:fixedPoint]; self.distanceLabel.text = [[NSString alloc] initWithFormat:@"Distance: %.1f feet", meters*3.2808399]; } 应该显示从用户到点的距离的标签不会不断更新,更新时通常不会显示从用户到固定点的正确距离。 我想知道是否有更好的方法来尝试这样做,或者做核心位置框架的根本局限性,这是不可能的。 任何帮助将不胜感激。

在iOS应用程序处于后台甚至死亡时获取位置信息

我的应用程序需要获取用户的位置,当应用程序处于活动状态,当它是无效的和死亡。 当用户的位置靠近商店时,应用程序必须发送本地通知。 我不确定到底发生了什么,但是我无法让我的应用程序在后台获取位置,并在死亡时将其唤醒。 我有一个位置pipe理器(singleton,用于两种情况whenInUse和Always),我有NSLocationAlwaysUsageDescription和NSLocationWhenInUseUsageDescription定义在.plist 我正在做的是: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //The app has been killed/terminated (not in background) by iOS or the user. if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]){ _locationManager = [CoreLocationManager sharedInstance]; _locationManager.isAppActive = NO; _locationManager.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; _locationManager.locationManager.activityType = CLActivityTypeOtherNavigation; if ([_locationManager.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { [_locationManager.locationManager requestAlwaysAuthorization]; } [_locationManager addLocationManagerDelegate:self]; } } – (void)applicationDidBecomeActive:(UIApplication *)application { […]

CLLocationManager didEnterRegion:与应用程序暂停时使用iBeacon

我试图唤醒我的应用程序(重新启动它),当它进入我定义的信标区域,但我不能得到它的工作。 这是我正在使用的步骤和代码。 将“位置更新”后台模式设置为YES。 监视我的CLBeaconRegion NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"EBEFD083-70A2-47C8-9837-E7B5634DF524"]; beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"daRegion"]; beaconRegion.notifyEntryStateOnDisplay = NO; beaconRegion.notifyOnEntry = YES; beaconRegion.notifyOnExit = YES; self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; [self.locationManager startMonitoringForRegion:beaconRegion]; 实现委托方法 – (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region; – (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region; – (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region; 任何我可能会错过的东西? 我已阅读文档,博客文章,论坛,似乎没有任何工作。 这是我阅读的网站之一, […]

根据用户当前在iOS7中的位置,RegionMonitoring监控的“region”的数量

我正在从事这样的项目,应用程序执行以下操作: 用户select一个半径(10米到1000米),然后按“Go”button进入下一个viewController 这里的应用程序抓住用户当前位置,并根据当前位置和选定的半径开始“区域监视” 如果用户跨越某个边界(10米到1000米),则会发出“ExitRegion”警报消息。 并根据用户新的当前位置再次启动“区域监控”。 而应用程序一直在做,无论是前景和背景模式。 我设法做到这一点,它正在完美的工作。 现在,我在这里监视一个地区,然后是另一个地区。 所以这个数字实际上是一个。 但我知道一个应用程序可以通过“区域监控”监控的区域的最大数量是15.现在我的问题是在这种情况下,我应该处理这个最大数量的区域问题吗? 如果是,那么如何? 还有一件事我想补充是,有一些解决scheme,它只适用于iOS 6和更早版本。 所以,请根据用户当前在iOS7中的位置,通过“RegionMonitoring”监控的“region”的处理数量来解决。 如果能够给出答案或任何build议来完成我的应用程序所需的要求,我将非常高兴。 先进的很多感谢。 祝你今天愉快。