偶然在一個demo中的找到了解決偏差的另外一種方法;<起初轉載了篇文章有兩種方法>
1, MKMapView *_mapView;
- (void)findMe:(id)sender{
self.cllocationManager = [[[CLLocationManageralloc]init]autorelease];
self.cllocationManager.delegate =self;//對應下面的委託方法121
self.cllocationManager.desiredAccuracy =kCLLocationAccuracyBest;
self.cllocationManager.distanceFilter =1.0f;
[self.cllocationManagerstartUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
weidu.text = [NSStringstringWithFormat:@"%3.5f",newLocation.coordinate.latitude];
jingdu.text = [NSStringstringWithFormat:@"%3.5f",newLocation.coordinate.longitude];
//以上的經度,維度若要對應此newLocation映射到地圖上面會有偏移,大家所謂的火星座標;而有時候我們需要方向編碼查出響應的位置等信息,獲取正確的信息我們可以以來之前申明的
//_mapView.userLocation.location由字面意思及用戶的位置信息,包含經度維度,等等
CLGeocoder *geocoder = [[CLGeocoderalloc]init];
[geocoder reverseGeocodeLocation: _mapView.userLocation.locationcompletionHandler:^(NSArray*array,NSError *error) {
if (array.count > 0) {
CLPlacemark *placemark = [array objectAtIndex:0];
NSString *country = placemark.ISOcountryCode;
NSString *city = placemark.locality;
NSLog(@"%@",placemark);
}
}];
// self.cllocationManager.distanceFilter = 1.0f; 距離變動有1m後回調此方法,然而此時我們又可以獲取到真實的location。
2012-12-23 01:33:42.819 MapDemo[28470:707]中國四川省成都市青羊區小關廟街37號,中國四川省成都市青羊區小關廟街37號 @ <+30.66883500,+104.08376400> +/- 100.00m, region (identifier <+30.66883500,+104.08376400> radius 62.07) <+30.66883500,+104.08376400> radius 62.07m
//修正了的信息
2012-12-23 01:31:43.256 MapDemo[28449:707]中國四川省成都市青羊區北書院街,中國四川省成都市青羊區北書院街 @ <+30.66629472,+104.08632278> +/- 100.00m, region (identifier <+30.66684850,+104.08665200> radius 93.92) <+30.66684850,+104.08665200> radius 93.92m