Hi, is there a way to make the MKMapView place a pin with a given address? Without using the Coordinates
Thanks
Hi, is there a way to make the MKMapView place a pin with a given address? Without using the Coordinates
Thanks
You need to use a geocoding service to convert your address to coordinates. Google, I think, offers one, along with a few other services.
here is a snippet of code I used in an application
-(CLLocationCoordinate2D) getLocationFromAddressString:(NSString*) addressStr {
    NSString *urlStr = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
                           [addressStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSString *locationStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlStr]];
    NSArray *items = [locationStr componentsSeparatedByString:@","];
    double lat = 0.0;
    double long = 0.0;
    if([items count] >= 4 && [[items objectAtIndex:0] isEqualToString:@"200"]) {
        lat = [[items objectAtIndex:2] doubleValue];
        long = [[items objectAtIndex:3] doubleValue];
    }
    else {
        NSLog(@"Address, %@ not found: Error %@",addressStr, [items objectAtIndex:0]);
    }
    CLLocationCoordinate2D location;
    location.latitude = lat;
    location.longitude = long;
    return location;
}