简体   繁体   中英

Mapkit multiple annotation

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 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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM