Skip to content

Instantly share code, notes, and snippets.

@mhennemeyer
Created March 15, 2011 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhennemeyer/871733 to your computer and use it in GitHub Desktop.
Save mhennemeyer/871733 to your computer and use it in GitHub Desktop.
- (NSString *)title {
return self.mTitle;
}
- (NSString *)subtitle {
return self.mSubTitle;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self.address = @"Goldbach 25, Bielefeld";
self.mTitle = @"Name der Werkstatt";
self.mSubTitle = @"Adresse der Werkstatt";
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.1;
span.longitudeDelta=0.1;
region.span=span;
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",
[self.address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
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];
}
else {
//Show error
}
coordinate.latitude = latitude;
coordinate.longitude = longitude;
region.center=coordinate;
[mapView addAnnotation:self];
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment