ios - 在ios中的谷歌地图上添加多个图钉

标签 ios ios5 ios6 annotations google-maps-sdk-ios

我想在加载谷歌地图时在谷歌地图上添加多个图钉。

我有附近位置的纬度和经度值的列表。 如何用图钉在 map 上显示所有这些位置。我正在使用适用于 iOS 的 Google SDK。

我正在使用以下代码,但它对我不起作用。

NSMutableArray *array = [NSMutableArray arrayWithObjects:@"12.981902,80.266333",@"12.982902,80.266363", nil];

CLLocationCoordinate2D pointsToUse[5];

for (int i = 0; i < [array Size]; i++)
{
    pointsToUse[i] = CLLocationCoordinate2DMake([[[[array objectAtIndex:0]  componentsSeparatedByString:@","] objectAtIndex:0] floatValue],[[[[array objectAtIndex:0]  componentsSeparatedByString:@","] objectAtIndex:1] floatValue]);

    [array removeObjectAtIndex:0];

    GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init];
    options.position = pointsToUse[i];
    [mapView_ animateToLocation:pointsToUse[i]];
    [mapView_ addMarkerWithOptions:options];
}

我已经尽力搜索它,但没有足够的文档来回答我的问题。

预先感谢您的帮助。

最佳答案

这对我有用:

for(GMSMarker*marker in array)
    {
        GMSMarker *mkr= [[GMSMarker alloc]init];
        [mkr setPosition:CLLocationCoordinate2DMake(<coord>)];

        [mkr setAnimated:YES];
        [mkr setTitle:<Title>];
        [mkr setSnippet:<Snippet>];
        [mkr setMap:mapView_];
    }

使用最新的 Google map SDK。

希望对你有帮助

关于ios - 在ios中的谷歌地图上添加多个图钉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16191436/

相关文章:

ios - 如何在 UITabBarController 中独立处理 View Controller ?

iphone - uiscrollview 内容大小的较大值是否会影响设备内存的分配?

iphone - 在 iOS5 中,我在图库中切换图片的方法很糟糕

iphone - 如何在我的 iPhone 应用程序中添加 Twitter 关注按钮?

objective-c - 当 iOS 设备锁定或应用程序处于后台时启动下载

ios - 无法将 NSManagedObjectContext 传递给我的 View Controller

ios - 如何以编程方式在 UINavigationController 中显示第二个模态 ViewController

ios - CIFourfoldRotatedTile 核心图像过滤器

ios - Apple iTunes 应用程序的限制

ios - Swift iOS-有wifi连接但没有互联网连接怎么办?