以下のループを使用して、MapViewにデータを入力します。ただし、何度繰り返しても、常に一度に1つのピンしか表示されません。
アイテムを個別に宣言することも影響を与えないようです。
osx10.5.8でxCode3.1.3を使用して最初の3.0SDKを使用しています。3.1SDKの変更ログにはMKMapKitフレームワークの修正についての言及がなかったため、2.5GBをダウンロードする必要性を感じていません。ファイル。
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];
}
これは最初のロギングステートメントから出力されます
Made Annotation London at N51.3 E0.07000000000000001
Made Annotation Amsterdam at N52.22 E4.53
そして二つ目は辞書の構造です
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";
}
興味のある方は、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
これはすべて組み合わされてこれを生成します...
代替テキストhttp://img340.imageshack.us/img340/3788/picture1fg.png
私が間違っているところに何かアイデアはありますか?ありがとう