【问题标题】:How to add annotation manually to map view in iOS?如何手动添加注释到 iOS 中的地图视图?
【发布时间】:2015-10-28 05:50:14
【问题描述】:

我想手动添加注释(当用户在地图视图中触摸特定位置时)并获取该位置的详细信息(纬度、经度、地址)..

【问题讨论】:

标签: ios mkmapview mapkitannotation


【解决方案1】:

@iPrabu 指向similar post,为您的问题提供了非常好的和正确的答案...对于第二部分,即获取有关该位置的详细信息..您可以这样做

-(void)getAddressFromCurruntLocation:(CLLocation *)location{

CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
 {
     if(placemarks && placemarks.count > 0)
     {
         CLPlacemark *placemark= [placemarks objectAtIndex:0];



         NSString *address = [NSString stringWithFormat:@"%@ %@",[placemark country],[placemark administrativeArea]];
// you may also get locality,sublocality,subadministrativeare etc
         NSLog(@"The Address Is:%@",address);
     }
 }];
}

快乐编码:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 1970-01-01
    相关资源
    最近更新 更多