IOS10 on iPhone 6 Plus. A small app app that grabs the gps coordinates and sends them to a remote web service. On the iphone map the user location is showing correctly, but the retrieved coordinates:
iPhone 6 Plus上的IOS10。一个小应用程序应用程序,它抓住gps坐标并将它们发送到远程Web服务。在iPhone地图上,用户位置显示正确,但检索到的坐标:
location.coordinate.latitude,
location.coordinate.longitude
are 0.5 miles away from where the map says I am! This is consistent wherever I move to.
离地图说我的地方0.5英里远!无论我搬到哪里,这都是一致的。
I am following Apple's best practices and using the delegate method as follows: and it's these coordinates that are incorrect.
我遵循Apple的最佳实践并使用委托方法,如下所示:这些坐标不正确。
// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
CLLocation* location = [locations lastObject];
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0) {
// Log the data
NSLog(@"latitude %+.6f, longitude %+.6f\n",
location.coordinate.latitude,
location.coordinate.longitude);
}
}
I am setting the location accuracy as follows:
我正在设置位置准确度如下:
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
I sample the gps coordinates for 30 seconds to make sure i am getting the best accuracy possible.
我将gps坐标采样30秒,以确保我获得最佳精度。
I have tried this on 2 different iPhones, both showing the same issue. Thanks in advance.
我在2个不同的iPhone上尝试了这个,两者都显示了同样的问题。提前致谢。
2 个解决方案
#1
1
I finally found out what is causing the problem.. I am currently in China... and that is the reason for the mysterious offset.. the maps in China are 'offset'. If you are interested there's an post about it here that has saved me from tearing my hair out. http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem.
我终于找到了造成这个问题的原因。我目前在中国......这就是神秘抵消的原因......中国的地图是“抵消”的。如果你有兴趣,这里有一篇关于它的帖子,这让我免于撕裂我的头发。 http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem。
China uses a mapping projection called GCJ-02 which is different from the West's mapping standard (WGS-84). So if you're ever developing a mapping system, you might want to take this into account for travellers in China!
中国使用名为GCJ-02的映射投影,它与西方的地图标准(WGS-84)不同。因此,如果您正在开发地图系统,您可能希望将此考虑在中国的旅行者中!
Thanks anyway for the useful pieces of coding advice.
无论如何,谢谢有用的编码建议。
#2
0
You can add a check in your method to update locations again until you are down to your desired accuracy:
您可以在方法中添加一个检查,以便再次更新位置,直到达到所需的准确度:
// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
// You can check for either locationManager.desiredAccuracy or a value you'd like in meters
CLLocation* location = [locations lastObject];
if (location.horizontalAccuracy > locationManager.desiredAccuracy) {
//Do nothing yet
return;
}
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0) {
// Log the data
NSLog(@"latitude %+.6f, longitude %+.6f\n",
location.coordinate.latitude,
location.coordinate.longitude);
}
}
#1
1
I finally found out what is causing the problem.. I am currently in China... and that is the reason for the mysterious offset.. the maps in China are 'offset'. If you are interested there's an post about it here that has saved me from tearing my hair out. http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem.
我终于找到了造成这个问题的原因。我目前在中国......这就是神秘抵消的原因......中国的地图是“抵消”的。如果你有兴趣,这里有一篇关于它的帖子,这让我免于撕裂我的头发。 http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem。
China uses a mapping projection called GCJ-02 which is different from the West's mapping standard (WGS-84). So if you're ever developing a mapping system, you might want to take this into account for travellers in China!
中国使用名为GCJ-02的映射投影,它与西方的地图标准(WGS-84)不同。因此,如果您正在开发地图系统,您可能希望将此考虑在中国的旅行者中!
Thanks anyway for the useful pieces of coding advice.
无论如何,谢谢有用的编码建议。
#2
0
You can add a check in your method to update locations again until you are down to your desired accuracy:
您可以在方法中添加一个检查,以便再次更新位置,直到达到所需的准确度:
// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
// You can check for either locationManager.desiredAccuracy or a value you'd like in meters
CLLocation* location = [locations lastObject];
if (location.horizontalAccuracy > locationManager.desiredAccuracy) {
//Do nothing yet
return;
}
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0) {
// Log the data
NSLog(@"latitude %+.6f, longitude %+.6f\n",
location.coordinate.latitude,
location.coordinate.longitude);
}
}