Iphone 如何从地址确定CLLocation或MKPlacemark?

Iphone 如何从地址确定CLLocation或MKPlacemark?,iphone,iphone-sdk-3.0,mapkit,geocoding,Iphone,Iphone Sdk 3.0,Mapkit,Geocoding,我看过API文档和一个又一个演示如何进行反向地理编码——在给定Lat/Long位置的情况下获取地址。我需要做相反的事情。我假设这个问题已经解决了,因为苹果的MapKit API完全避免了这个问题。一种方法是像这样使用google Web服务: -(CLLocationCoordinate2D) addressLocation { NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/g

我看过API文档和一个又一个演示如何进行反向地理编码——在给定Lat/Long位置的情况下获取地址。我需要做相反的事情。我假设这个问题已经解决了,因为苹果的MapKit API完全避免了这个问题。

一种方法是像这样使用google Web服务:

-(CLLocationCoordinate2D) addressLocation {
    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
                           [addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
    NSLog(@"locationString = %@",locationString);

    NSArray *listItems = [locationString componentsSeparatedByString:@","];

    double latitude = 0.0;
    double longitude = 0.0;
    if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {
        latitude = [[listItems objectAtIndex:2] doubleValue];
        longitude = [[listItems objectAtIndex:3] doubleValue];
/*      
        NSString *nameString = [NSString stringWithFormat:@"http://ws.geonames.org/findNearestAddress?lat=%f&lng=%f",latitude,longitude];
        NSString *placeName = [NSString stringWithContentsOfURL:[NSURL URLWithString:nameString]];
        NSLog(@"placeName = %@",placeName);
 */
    }
    else {
        //Show error
    }
    CLLocationCoordinate2D location;
    location.latitude = latitude;
    location.longitude = longitude;

    return location;

}