我有一个删除多个注释的应用程序,我想对引脚位置进行反向地理编码并将地址设置为字幕。这是我到目前为止的代码,但我不知道如何实现反向地理编码器。
-(void)press:(UILongPressGestureRecognizer *)recognizer
{
CGPoint touchPoint = [recognizer locationInView:worldView];
CLLocationCoordinate2D touchMapCoordinate = [worldView convertPoint:touchPoint toCoordinateFromView:worldView];
if (UIGestureRecognizerStateBegan == [recognizer state]) {
MapPoint *mp = [[MapPoint alloc]initWithCoordinate:touchMapCoordinate
title:@"Dream House"];
[worldView addAnnotation:mp];
geocoder = [[CLGeocoder alloc]init];
CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
altitude:CLLocationDistanceMax
horizontalAccuracy:kCLLocationAccuracyBest
verticalAccuracy:kCLLocationAccuracyBest
timestamp:[NSDate date]];
[geocoder reverseGeocodeLocation:location
completionHandler:^(NSArray *placemarks, NSError *error) {
<#code#>
}];
}
}
别针会掉在家里,所以我只想显示房子地址。谢谢您的帮助。