Reputation:
I've been adding MapView into my ViewController. Code as below:
MapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
MKCoordinateRegion region;
region.center.latitude = [[myStore.Location objectAtIndex:0] doubleValue];
region.center.longitude = [[myStore.Location objectAtIndex:1] doubleValue];
MKCoordinateSpan span;
span.latitudeDelta = .0015;
span.longitudeDelta = .0015;
region.span = span;
[MapView setRegion:region animated:YES];
myStore.Location
is an array with coordinates. XCode just crashes the app and return the error at [MapView setRegion:region animated:YES];
which i assume that it cannot init the mapview, can anyone help?
Upvotes: 0
Views: 483
Reputation:
i've resolved my problem... the latitude and longitude was being reversed. [myStore.Location objectAtIndex:0]
should be the longitude and [myStore.Location objectAtIndex:1]
should be the latitude... silly me.
Upvotes: 2