【发布时间】:2011-07-06 04:37:19
【问题描述】:
我想用 iphone gps 功能显示用户的当前位置,但问题是它给出的位置不正确。 当我在地图上放下大头针时,它会将大头针放在确切的位置,但是当我尝试查看文本中的位置时,它给出的位置不准确,大约 500 到 800 米的不准确度。我使用了反向地理编码和谷歌 api,但都给出了相同的位置.请告诉我为什么会发生这种情况以及如何显示用户的确切位置? 我的代码是:
cllocationmanager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyBest; // 100 m
[locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D here = newLocation.coordinate;
NSLog(@"%f %f ", here.latitude, here.longitude);
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:here];
[geocoder setDelegate:self];
[geocoder start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"The geocoder has returned: %@", [placemark addressDictionary]);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",[placemark addressDictionary]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
【问题讨论】:
-
您能说一下您是如何验证位置的吗?您是否正在使用具有不同基准的地图?
标签: iphone objective-c gps mapkit