我想在加载谷歌地图时在谷歌地图上添加多个图钉。
我有附近位置的纬度和经度值的列表。
我怎样才能用图钉在地图上显示所有这些位置。我正在使用适用于 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 地图 SDK。
希望能帮助到你
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)