I can't add multiple annotation to my view. It only adds one.Here is my code. Thanks.
const char *sql1=[final1 UTF8String];
sqlite3_stmt *statement1;
if(sqlite3_prepare_v2(database,sql1,-1,&statement1,NULL)==SQLITE_OK)
{
tableData1=[[NSMutableArray alloc] init];
while (sqlite3_step(statement1) == SQLITE_ROW)
{
l++;
NSLog(@"numar de lapuri%d",l);
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 0)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 1)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 2)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 3)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 4)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 5)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 6)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 7)]];
[tableData1 addObject:[NSString stringWithFormat:@"%s",(char*)sqlite3_column_text(statement1, 8)]];
NSString* laplat=[tableData1 objectAtIndex:7];
NSString* longlat=[tableData1 objectAtIndex:8];
NSLog(@"lap lat:%@",laplat);
NSLog(@"lap lat:%@",longlat);
lapcoord.latitude=[laplat doubleValue];
lapcoord.longitude=[longlat doubleValue];
annotation=[[AnnotationDelegate 开发者_JAVA技巧alloc] initWithCoordinate:lapcoord];
[mapView addAnnotation:annotation];
[annotation release];
NSLog(@"added");
}
NSLog(@"Works lap");
}
You have to keep an array for the annotations and use
[mapView addAnnotations:annotationsArray];
精彩评论