[英]How to create a CLLocationCoordinate2d object
我试图调用MKPolylines + polylineWithCoordinates:count:
方法。
在这种情况下,如何创建CLLocationCoordinate2D *对象。 我在CLLocationCoordinate2D中经历了这个特定的答案, 却不知道数组中会有多少个?
// unpacking an array of NSValues into memory
CLLocationCoordinate2D *points = malloc([mutablePoints count] * sizeof(CLLocationCoordinate2D));
for(int i = 0; i < [mutablePoints count]; i++) {
[[mutablePoints objectAtIndex:i] getValue:(points + i)];
}
MKPolyline *myPolyline = [MKPolyline polylineWithCoordinates:points count:[mutablePoints count]];
free(points);
在上述情况下,数组mutablePoints中有哪些条目?
如果您的问题只是数组中的哪种类型,答案很简单: NSValue
条目。 您可以查看本指南以获取有关如何使用NSValues
更多信息。
CLLocationCoordinate2D coordinate;
for (int i = 0; i < arr.count; i++)
{
float t1 = [[arr objectAtIndex:1] floatValue];
float t2 = [[arr objectAtIndex:0] floatValue];
coordinate.latitude = t1;
coordinate.longitude = t2;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.