Tag: 核心位置

寻找CLLocationCoordinate2D点之间的距离

我从文档中知道我们可以使用函数distanceFromLocation:find两个CLLocation点之间的distanceFromLocation: 。 但我的问题是我没有CLLocation数据types与我,我有CLLocationCoordinate2D点。 那么我怎样才能find两个CLLocationCoordinate2D点之间的距离。 我看过post,但对我没有帮助。

在Xcode 4.2 / iOS5中模拟包括移动的位置

我已经看到苹果在iOS5中演示了新的模拟器function,除了静态位置之外,他们展示了模拟运行在模拟器上的应用程序位置移动的能力。 我已经使用GPX文件成功地模拟了单个位置,但我找不到任何模拟移动的方法。 这个function是否在最后一分钟掉线了,还是我错过了一些明显的东西?

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

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

IBeacon区域监视在设备间不一致

当testing一个简单的应用程序来testing信标区域监控,我似乎得到非常不一致的结果取决于设备(不是设备型号,特定的设备)。 问题是,在requestStateForRegion之后,我没有在区域上收到CLRegionStateInside状态, didEnterRegion在这些设备上根本没有被调用。 startRangingBeaconsinRegion :工作正常,但为了节约能源和处理,build议只在didEnterRegion :方法被调用时才开始测距。 我testing了这个在6个设备上,它在他们的一半(iPhone 5的),并没有在一个iPhone 5,一个5S和一个4S 。 我使用的信标是kontakt.io信标。 这是设置区域监视的代码 self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:BEACON_UUID]; CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"regionIdentifier"]; region.notifyOnEntry = YES; region.notifyOnExit = YES; region.notifyEntryStateOnDisplay = YES; [self.locationManager startMonitoringForRegion:region]; [self.locationManager requestStateForRegion:region]; //If I enable this line, ranging starts on all […]

用户拒绝位置服务后再次请求权限?

我跟踪用户的位置,并要求我的负载第一次加载时使用此权限: locationManager.requestAlwaysAuthorization() locationManager.startUpdatingLocation() 如果用户拒绝,但稍后通过在应用程序中启用configuration选项来改变他们的想法,我该如何再问? 例如,我有一个开关来自动检测用户的位置,所以当他们启用它时,我正在尝试这样做: @IBAction func gpsChanged(sender: UISwitch) { // Request permission for auto geolocation if applicable if sender.on { locationManager.requestAlwaysAuthorization() locationManager.startUpdatingLocation() } } 但是这个代码似乎没有做任何事情。 我希望它会再次询问用户是否允许应用程序跟踪用户的位置。 这可能吗?

在iOS 10中测距信标

在我的应用程序中,我使用CoreLocation中的Beacon Region Monitoring。 该应用程序设置2 proximityUUID作为地区(他们有不同的ID),并开始测距如下。 #pragma mark – CLLocationManagerDelegate (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { [self.locationManager requestStateForRegion:(CLBeaconRegion *)region]; } – (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { [self.locationManager stopRangingBeaconsInRegion:(CLBeaconRegion *)region]; } – (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region{ for(CLBeacon* b in beacons){ //output only previous beacon if it's before regionout to previous region NSLog(@"%@",b); } } – (void)locationManager:(CLLocationManager […]

iOS定位服务访问和系统频繁定位

我注意到iPhone上的频繁定位似乎比监控iOS访问( https://developer.apple.com/reference/corelocation/clvisit )的应用程序使用更less的电池。 在iPhone上频繁的位置可以在手机上通过设置 – >隐私 – >定位服务 – >系统服务 – >频繁地点查看。 我想知道来自CLLocationManager的访问监控服务是否与iOS常用位置相同,或者是否与苹果使用的系统不同。 如果苹果使用相同的服务,为什么它不会对电池产生任何影响?

locationManager:rangingBeaconsDidFailForRegion:withError:kCLErrorDomain 16

我读过CLLocationManager kCLErrorDomain代码? 以及Apple Docs 我调用startRangingBeaconsInRegion之前检查以确保范围可用:我还检查在locationManager中的range是否可用:rangingBeaconsDidFailForRegion:withError:method。 两次都返回true。 当我得到的监视区域的集合,我的信标是在集(所以注册监测工作)。 我已经看到,错误16可能意味着测距不可用,蓝牙可能closures,位置服务可能会closures,飞行模式可以打开,我已经检查了他们所有都可用并正在运行(显然不是飞行模式)。 什么可能导致测距失败,每次我运行应用程序?

CLGeocoder reverseGeocodeLocation返回“kCLErrorDomain错误9”

我正在根据这篇文章开发一个具有反向地理编码function的iOS应用程序: 地理编码教程 但是,当我在模拟器上这样testing,我得到'kCLErrorDomain错误9'。 我搜查了很多,只有错误0或1不是9。 这是我在viewDidLoad代码: self.locationManager = [[CLLocationManager alloc]init]; self.locationManager.delegate = self; self.locationManager.distanceFilter = 80.0; [self.locationManager startUpdatingLocation]; CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease]; [geocoder reverseGeocodeLocation:self.locationManager.location completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!"); if (error){ NSLog(@"Geocode failed with error: %@", error); return; } if(placemarks && placemarks.count > 0) { //do something CLPlacemark *topResult […]

获取用户的当前位置iOS 8.0

我试图让用户使用MapKit和CoreLocation的当前位置。 我是Objective-C的新手。 至于我的研究,这个实现和旧的iOS到iOS 8.0稍有不同。 我一切正确。 仍然是获得当前的位置。 我的实际目标是在用户在文本字段中提供位置时,在运行时获取pinkit用户位置。 filename.h #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface LocationSelectionViewController : UIViewController <CLLocationManagerDelegate> @property (weak, nonatomic) IBOutlet UITextField *insertLocation; @property (strong, nonatomic) IBOutlet MKMapView *serviceLocation; – (IBAction)next:(id)sender; @end #import "LocationSelectionViewController.h" #import <CoreLocation/CoreLocation.h> @interface LocationSelectionViewController () <CLLocationManagerDelegate> @end @implementation LocationSelectionViewController CLLocationManager *locationManager; @synthesize serviceLocation; – (void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager […]