位置经理的准确性不是很准确

我正在向其他用户发送位置信息。 我使用Parse.com作为我的后端,并使用此代码来获取位置:

-(void)sendLocation{ if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){ [locationManager requestWhenInUseAuthorization]; } [locationManager startUpdatingLocation]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { [locationManager stopUpdatingLocation]; //kill it NOW or we have duplicates if(!self.haveLocation) { self.haveLocation=YES; NSLog(@"didUpdateToLocation: %@", newLocation); self.currentLocation = newLocation; self.currentLocationGeoPoint= [PFGeoPoint geoPointWithLocation:self.currentLocation]; } 

如果我从我目前的位置发送一条消息,然后打开消息来查看它,通过比较当前的位置圈与引脚下降,我可以看到他们不在相同的地方和相当的距离。

我有BOOL var haveLocation来确保它只刷新一次。 我需要更多次刷新吗? 任何关于如何使这个更准确的指针将非常感激! 谢谢

我试过下面的苹果示例LocateMe:

我现在有:

 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; if (locationAge > 5.0) return; // test that the horizontal accuracy does not indicate an invalid measurement if (newLocation.horizontalAccuracy < 0) return; // test the measurement to see if it is more accurate than the previous measurement if (self.bestEffortAtLocation == nil || self.bestEffortAtLocation.horizontalAccuracy > newLocation.horizontalAccuracy) { // store the location as the "best effort" self.bestEffortAtLocation = newLocation; if (newLocation.horizontalAccuracy <= locationManager.desiredAccuracy) { [locationManager stopUpdatingLocation]; //this code after getting the location NSLog(@"didUpdateToLocation: %@", newLocation); } } 

}

但是,当我点击发送位置它只是永远运行,不停止更新..我有locationManager.desiredAccuracy = kCLLocationAccuracyBest; 也设置。

位置pipe理器可以向您发送几个更新,因为它提高了准确性。 这是一个function,旨在尽可能快地为您提供信息,同时最终为您提供最好的信息(至less达到您要求的准确度)。 你正在积极地避免这些更新,所以你可能会得到最不准确的信息。

你应该检查horizontalAccuracy以确定它是否足够准确供您使用。

请注意,您无法将horizontalAccuracykCLLocationAccuracyBest进行比较。 “最好”是一个常数-1。 您需要将其与您需要的数值(以米为单位)进行比较,如果时间过长,可能会设置超时以放弃(系统可能无法为您提供任意准确的值)。