Mapkit 多重注释

发布于 2024-11-04 21:29:49 字数 2068 浏览 0 评论 0原文

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

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");
        }

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");
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随风而去 2024-11-11 21:29:49

您必须保留一个用于注释的数组并使用

[mapView addAnnotations:annotationsArray];

You have to keep an array for the annotations and use

[mapView addAnnotations:annotationsArray];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文