Mapkit多个注释

时间:2011-05-05 08:34:09

标签: iphone ios annotations mapkit

我无法在视图中添加多个注释。它只添加一个。这是我的代码。感谢。

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 alloc] initWithCoordinate:lapcoord];
                [mapView addAnnotation:annotation];
                [annotation release];
                NSLog(@"added");
            }
            NSLog(@"Works lap");
        }

1 个答案:

答案 0 :(得分:1)

您必须为注释保留数组并使用

[mapView addAnnotations:annotationsArray];