Search code examples
iosmapkitmkannotationcllocationcllocationcoordinate2d

MapKit CLLocationCoordinate2D putting me in the wrong location


This should be Los Angeles:

double latitude = 34.05;
double longitude = 118.25;

CLLocationCoordinate2D location = CLLocationCoordinate2DMake(latitude, longitude);

NSString *desc = @"hey there";
NSString *address = @"some address";

CLLocationCoordinate2D coordinate;
coordinate.latitude = location.latitude;
coordinate.longitude = location.longitude;
MyLocation *annotation = [[MyLocation alloc] initWithName:desc address:address coordinate:coordinate]; //implements <MKAnnotation>

NSArray *annotations = @[annotation];
[self.mapView showAnnotations:annotations animated:YES];

However this annotation ends up in Eastern China. What am I missing in the conversion?


Solution

  • I think you want -118.25 degrees for Los Angles.