I have an iOS application which parses some data from a JSON feed. One of the bit of downloaded data is a set of coordinates. I am trying to get those coordinates and display them on a MapView in iOS. But I get the following error:
initializing 'cllocationcoordinate2d' with an expression of incompatible type 'id'
Here is my code:
int choose = 4;
NSArray *location_lat = [[[res objectForKey:@"data"] valueForKey:@"location"] valueForKey:@"latitude"];
NSArray *location_long = [[[res objectForKey:@"data"] valueForKey:@"location"] valueForKey:@"longitude"];
NSLog(@"\n\nLat:%f Lon:%f", [location_lat[choose] doubleValue], [location_long[choose] doubleValue]);
CLLocationCoordinate2D lat = [location_lat[choose] doubleValue];
CLLocationCoordinate2D lon = [location_long[choose] doubleValue];
MKCoordinateRegion region = { {0.0, 0.0}, {0.0, 0.0} };
region.center.latitude = lat;
region.center.longitude = lon;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[map setRegion:region animated: YES];
ContentView *ann = [[ContentView alloc] init];
ann.title = @"Current Location";
ann.subtitle = @"";
ann.coordinate = region.center;
[map addAnnotation:ann];
I don't understand what I am doing wrong... Please help.
Thanks, Dan.