Tag: cllocation

获取半径内的位置

我正在开发iOS应用程序,我想在其中查找某个半径内的所有位置。 在objective-c中有什么办法可以让我指定一个固定的半径和位置,这将告诉我哪个位置在这个半径内? 我做了一些研究,我得到了这个代码片段, – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:locationManager.location completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!"); if (error) { NSLog(@"Geocode failed with error: %@", error); return; } CLLocationDistance radius = 30; CLLocation* target = [[CLLocation alloc] initWithLatitude:51.5028 longitude:0.0031]; NSArray *locationsWithinRadius = [placemarks objectsAtIndexes: […]

如何发送坐标来parsing并保存为parsingPFGeopoint

我怎样才能发送坐标到由CLLocation获取的parsing并将其保存为PFGeoPoint的经度和纬度? 我能够从CLLocation获取坐标,我想将它发送给Parse。 在parsing我有一个名为“坐标”PFGeoPointtypes有两个字段的列。现在我想保存我从CLLocation获取的坐标到parsing列坐标。 任何人都可以请帮我这个? 我是iOS和Parse的新手。

我如何评估GPS信号强度? (苹果手机)

我需要一种分类GPS信号强度的方法。 到目前为止,我遇到了CLLocation ( Class Reference )的horizontalAccuracy属性。 更具体地说,我需要创build如下的东西。 我遇到的问题是填写if语句。 if (someLocation.horizontalAccuracy …) { // No Signal } else if (someLocation.horizontalAccuracy …) { // Poor Signal } else if (someLocation.horizontalAccuracy …) { // Average Signal } else if (someLocation.horizontalAccuracy …) { // Good Signal } else { // Excellent Signal } 请有人可以帮我吗?

以每x秒的速度更新一个标签

我正在开发我的第一个iPhone应用程序。 我必须每x秒更新一次设备速度的标签。 我已经创build了自己的CLController并且可以获得设备速度,但是我不知道是否必须使用NSTimer更新我的标签。 我该怎么做?

更新从CLGeocoder返回的CLPlacemark的MKMapView

我希望能够通过允许用户在UIAlertView中input地址或位置来更新显示在MKMapView上的区域。 我目前有: if (geocoder.geocoding) [geocoder cancelGeocode]; [geocoder geocodeAddressString:[[alertView textFieldAtIndex:0] text] completionHandler:^(NSArray *placemarks, NSError *error) { if (!error) { NSLog(@"Found a location"); } else { NSLog(@"Error in geocoding"); } NSLog(@"Num found: %d", [placemarks count]); CLPlacemark *placemark = [placemarks objectAtIndex:0]; MKCoordinateRegion region; region.center.latitude = placemark.region.center.latitude; region.center.longitude = placemark.region.center.longitude; MKCoordinateSpan span; double radius = placemark.region.radius / 1000; NSLog(@"Radius […]

使用CLLocation计算两个坐标之间的距离

我正在使用CLLocationDistance获得两点之间的距离,但是当我将当前位置传递给它时,出现错误。 CLLocation *current = [[CLLocation alloc] initWithLatitude:startLocation.coordinate.latitude longitude:startLocation.coordinate.longitude]; CLLocation *itemLoc = [[CLLocation alloc] initWithLatitude:[[[getName objectAtIndex:indexPath.row] objectForKey:@"lat"] doubleValue] longitude:[[[getName objectAtIndex:indexPath.row] objectForKey:@"lon"] doubleValue]]; //Here the current location gives me an error "Initializing cllocation with an expression incompatible format" CLLocationDistance *itemDist = [itemLoc distanceFromLocation:current]; NSLog(@"Distance: %@", itemDist);

iOS Swift – CLGeocoder completionHandler块

我试图parsing一个位置(CLLocation)到一个string。 func locationToString (currentLocation: CLLocation) -> String? { var whatToReturn: String? CLGeocoder().reverseGeocodeLocation(currentLocation, completionHandler: { (placemarks: [AnyObject]!, error: NSError!) in if error == nil && placemarks.count > 0 { let location = placemarks[0] as CLPlacemark whatToReturn = "\(location.locality) \(location.thoroughfare) \(location.subThoroughfare)" } }) return whatToReturn } 显然,whatToReturn总是返回null,因为completionHandler在后台运行。 我很难理解在completionHandler完成时如何更新我的string? 谢谢。

didUpdateLocation方法从未调用

我正在iphone sdk4.0上做一个应用程序。在那个更新的位置方法从来没有调用。 我已经给我的代码below.Please help.Thanks提前。 -(id)init { [super init]; obj=[[UIApplication sharedApplication]delegate]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; //locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m [locationManager startUpdatingLocation]; return self; } -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"%f",newLocation.coordinate.latitude); NSLog(@"%f",newLocation.coordinate.longitude); obj=[[UIApplication sharedApplication]delegate]; location=[[CLLocation alloc]initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude]; obj.lattitude1=[NSString stringWithFormat:@"%f",newLocation.coordinate.latitude]; obj.longitude1=[NSString stringWithFormat:@"%f",newLocation.coordinate.longitude]; //location=[[CLLocation […]

如何存储CLLocationCoordinate2D?

我正在尝试构build一个应用程序来构build和保存类似于映射我的运行的路线。 我使用的是Breadcrumb示例代码,特别是CrumbPath和CrumbPathView作为我的路线的基础,从苹果。 两个问题: 如果我尝试访问MKMapPoint *points对象, CrumbPath所示: [_route lockForReading]; NSLog(@"%@", _route.points); NSLog(@"%d", _route.pointCount); [_route unlockForReading]; 我的应用程序崩溃,说: Thread 1: EXC_BAD_ACCESS (code: 1, address: 0x9450342d) 我很难理解,因为在CrumbPath.m文件中,苹果公司的人们通过明确地获取写入锁,然后解锁它来写入“数组”,然后解锁它,但是如果我获得读取锁并尝试读取它,它崩溃。 我尝试访问points的原因是试图获取MKMapPoints ,将它们转换为CLLocationCoordinate2D对象,并保存它们,以便我可以根据用户的要求重新绘制多段polyline 。 由于我无法访问这些points ,因此我尝试从我的locationManager保存CLLocationCoordinate2D对象,该对象发送给数组中的_route传到我的Parse后端,但是我总是得到一个错误: Sending 'CLLocationCoordinate2D' to parameter of incompatible type 'id' 这并没有使这个更容易。 有没有人有任何见解,为什么我得到这些错误? 位置经理代表 -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { if (_userLocation.longitude != manager.location.coordinate.longitude && _userLocation.latitude != manager.location.coordinate.latitude) { _userLocation = […]

horizo​​ntalAccuracy究竟意味着什么?

我正在使用位置服务的iOS应用程序。 在实验物理学的背景下,我想知道在locationManager:didUpdateToLocation:fromLocation:find的locationManager:didUpdateToLocation:fromLocation:究竟是什么horizontalAccuracy locationManager:didUpdateToLocation:fromLocation:代表。 文档有点稀疏 我假设准确性给出了基于高斯(或泊松?)分布的置信区间。 因此,在一定概率下,实际位置在horizontalAccuracy精度半径的圆内,但也可以在该区域外。 那么问题是:这个概率有多大? 如果horizontalAccuracy对应于1σ,那么我将有一个概率为68%的horizontalAccuracy精度在这个圆圈内,但是反过来看,在接近三分之一的情况下,实际的位置将在这个区域之外。 因此,在某些情况下,我宁愿用2σ( 2*horizontalAccuracy )甚至3σ( 3*horizontalAccuracy )来计算。 简而言之:有什么迹象表明,哪个置信区间horizontalAccuracy有? 对所有回应“苹果说它在…之内”的人说:呃 – 测量不准确。 它必须有一定的不确定性。 如果你经常重复测量,你会得到一个结果分布 – 可能是一个高斯分布。 这个高斯具有一定的宽度,这对应于测量的不确定性水平。 经常测量位置会降低不确定性,从而提高准确性,但绝对不会给你一个明确的间隔,确保实际的位置。你只会得到一个概率。 但是,如果精度是3sigma,我们有99.7% – 这是接近一定的。 简而言之 – 我怀疑苹果的文档。