Created
June 13, 2011 00:33
-
-
Save sergiobuj/1022166 to your computer and use it in GitHub Desktop.
Working with coordinates in iOS
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
for (NSDictionary *dict in [samplePlist objectForKey:@"map_points"]) { | |
// NSLog(@"%lf %lf %@", [[dict objectForKey:@"latitude"] doubleValue], [[dict objectForKey:@"longitude"] doubleValue], [dict objectForKey:@"title"]); | |
CLLocationCoordinate2D coord = { [[dict objectForKey:@"latitude"] doubleValue] , [[dict objectForKey:@"longitude"] doubleValue] }; | |
MPoint *point = [[MPoint alloc] initWithCoordinate:coord]; | |
[point setTitle:[dict objectForKey:@"title"]]; | |
[points addObject:point]; | |
[point release]; | |
} | |
[mapview addAnnotations:points]; | |
MKCoordinateRegion region; | |
region.center.latitude = [[points objectAtIndex:0] coordinate].latitude; | |
region.center.longitude = [[points objectAtIndex:0] coordinate].longitude; | |
region.span.longitudeDelta = 0.000796f; | |
region.span.latitudeDelta = 0.000908f; | |
[mapview setRegion:region animated:YES]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment