gpt4 book ai didi

ios - 将 GMS 标记分配给 NSMutableArray Objective-C

转载 作者:行者123 更新时间:2023-11-28 21:16:56 26 4
gpt4 key购买 nike

我已经使用“for”大小写从网络服务中成功显示了我的所有标记,这是我的方法

- (void)setMarker{
double double_lat;
double double_long;

for(int i=0;i<[ObjekwisataArray count];i++)
{
double_lat = [[[ObjekwisataArray objectAtIndex:i]valueForKey:@"latitude"] doubleValue];
double_long = [[[ObjekwisataArray objectAtIndex:i]valueForKey:@"longitude"] doubleValue];
GMSMarker *mkr = [[GMSMarker alloc] init];
if (double_lat !=0 && double_long!=0)
{
[mkr setPosition:CLLocationCoordinate2DMake(double_lat, double_long)];
[mkr setTitle:[[ObjekwisataArray objectAtIndex:i] valueForKey:@"nama"]];
[mkr setSnippet:@"Kota Ambon"];
[mkr setMap:NearbyView];
}

}}

现在我想问的是,当所有的纬度和经度都被调用时,如何将我的“mkr”变量(GMSMarker)存储到 NSMutableArray 值,我希望我的标记存储为 NSMutableArray 类型,这样我就可以我想随时打电话。谢谢你的回答

最佳答案

NSMutableArray *arr = [NSMutableArray new];

for(int i=0;i<[ObjekwisataArray count];i++)
{
double_lat = [[[ObjekwisataArray objectAtIndex:i]valueForKey:@"latitude"] doubleValue];
double_long = [[[ObjekwisataArray objectAtIndex:i]valueForKey:@"longitude"] doubleValue];
GMSMarker *mkr = [[GMSMarker alloc] init];
if (double_lat !=0 && double_long!=0)
{
[mkr setPosition:CLLocationCoordinate2DMake(double_lat, double_long)];
[mkr setTitle:[[ObjekwisataArray objectAtIndex:i] valueForKey:@"nama"]];
[mkr setSnippet:@"Kota Ambon"];
[mkr setMap:NearbyView];
[arr addObject:mkr];
}
}}

更新了!

关于ios - 将 GMS 标记分配给 NSMutableArray Objective-C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41020905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com