OGeek|极客世界-中国程序员成长平台

标题: ios - 在 ios 的谷歌地图上添加多个图钉 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 02:25
标题: ios - 在 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_ addMarkerWithOptionsptions];
}

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

提前感谢您的帮助。



Best Answer-推荐答案


这对我有用:

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 Maps SDK。

希望对你有帮助

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4