找到Apple内部对MKUserLocation去除偏移的方法。
[MKLocationManager _applyChinaLocationShift:(CLLocation*)arg]
这个方法返回去除偏移后的CLLocation*。
Code:
@ interface MKLocationManager
- (CLLocation*)_applyChinaLocationShift:(CLLocation*)arg;
- (BOOL)chinaShiftEnabled;
+ (id)sharedLocationManager;
@ end
CLLocationManager's Delegate:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if ([[MKLocationManager sharedLocationManager] chinaShiftEnabled]) {
newLocation = [[MKLocationManager sharedLocationManager] _applyChinaLocationShift:newLocation];
if (newLocation == nil) return;
}
}
[MKLocationManager _applyChinaLocationShift:(CLLocation*)arg]
这个方法返回去除偏移后的CLLocation*。
Code:
@ interface MKLocationManager
- (CLLocation*)_applyChinaLocationShift:(CLLocation*)arg;
- (BOOL)chinaShiftEnabled;
+ (id)sharedLocationManager;
@ end
CLLocationManager's Delegate:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if ([[MKLocationManager sharedLocationManager] chinaShiftEnabled]) {
newLocation = [[MKLocationManager sharedLocationManager] _applyChinaLocationShift:newLocation];
if (newLocation == nil) return;
}
}