在ios上的谷歌地图上添加多个引脚
问题描述:
我想在谷歌地图上添加多个引脚,当它正在加载时。
I want to add multiple pins on a google map, while it is being loaded.
我有一个附近位置的纬度和经度值列表。
如何使用别针在地图上显示所有这些位置。我正在使用适用于iOS的Google SDK。
I have a list of Latitude and Longitude values of nearby locations. How can I show all these locations on the map with a pin. I am using Google SDK for iOS.
我使用以下代码,但它对我不起作用。
I am using the following code, but it didn't work for me.
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];
}
我已经尝试过搜索它但是没有足够的文档来回答我的问题。
I have tried enough to search for it but there isn't enough documentation to answer my question.
提前感谢您的帮助。
答
这对我有用:
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。
Using latest Google Maps SDK.
希望有帮助