我有一个删除多个注释的应用程序,我想反转地理编码引脚位置并将地址设置为副标题。这是我到目前为止的代码,但我不知道如何实现反向地理编码器。
-(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#>
}];
}
}
针脚会落在家里,所以我只想显示房屋地址。谢谢你的帮助。