Created
March 15, 2011 23:34
-
-
Save mhennemeyer/871733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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