I use the loop below to populate my MapView. However it always shows only one pin at a time, no matter how many iterations i do.
Individually declaring items doesn't seem to have an impact either.
I'm using the initial 3.0 SDK with xCode 3.1.3 on osx 10.5.8, The 3.1 SDK changelog didn't make any mention of any fixes to the MKMapKit framework, so i haven't felt the need to download the 2.5GB file.
for(NSDictionary* dict in results ){
NSLog(@"Made Annotation %@ at N%f E%f", [dict valueForKey:@"location"],[dict valueForKey:@"latitude"],[dict valueForKey:@"longitude"] );
NSLog(@"List of keys %@", dict);
LTAnnotation* pin = [[LTAnnotation alloc] initWithTitle: [dict valueForKey:@"location"]
latitude: [dict objectForKey:@"latitude"]
longitude: [dict objectForKey:@"longitude"]
];
[MapView addAnnotation: pin];
}
This is output from the first logging statement
Made Annotation London at N51.3 E0.07000000000000001
Made Annotation Amsterdam at N52.22 E4.53
And the second is structure of the dictionary
List of keys {
id = 0;
latitude = 51.3;
location = London;
longitude = 0.07000000000000001;
time = "12:00-13:00";
}
List of keys {
id = 1;
latitude = 52.22;
location = Amsterdam;
longitude = 4.53;
time = "12:00-13:00";
}
In case your interested here's my implementation of LTAnnotation
@interface LTAnnotation(Private)
double longitude;
double latitude;
@end
@implementation LTAnnotation
@synthesize title;
@synthesize subTitle;
-(id) initWithTitle:(NSString*)pTitle latitude:(NSNumber*)latDbl longitude:(NSNumber*) longDbl{
self = [super init];
self.title = pTitle;
latitude = [latDbl doubleValue];
longitude = [longDbl doubleValue];
NSLog(@"Create Annotation for %@ at %fN %fE",pTitle,[latDbl doubleValue],[longDbl doubleValue]);
return self;
}
-(CLLocationCoordinate2D) coordinate
{
CLLocationCoordinate2D retVal;
retVal.latitude = latitude;
retVal.longitude = longitude;
return retVal;
}
@end
This all combines to produce this ...
Any ideas at where i'm going wrong? Thanks