Skip to content

Instantly share code, notes, and snippets.

@sergiobuj
Created June 13, 2011 00:33
Show Gist options
  • Save sergiobuj/1022166 to your computer and use it in GitHub Desktop.
Save sergiobuj/1022166 to your computer and use it in GitHub Desktop.
Working with coordinates in iOS
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