-(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;
}