简体   繁体   English

如何创建CLLocationCoordinate2d对象

[英]How to create a CLLocationCoordinate2d object

I am trying to to call MKPolylines' + polylineWithCoordinates:count: method. 我试图调用MKPolylines + polylineWithCoordinates:count:方法。

How can I create a CLLocationCoordinate2D * object in this case. 在这种情况下,如何创建CLLocationCoordinate2D *对象。 I have gone through this particular answer in CLLocationCoordinate2D without knowing how many will be in the array? 我在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);

What kind of entries are in the array mutablePoints in the above case? 在上述情况下,数组mutablePoints中有哪些条目?

If your question is simply what kind of entries are in the array, the answer is quite simple: NSValue entries. 如果您的问题只是数组中的哪种类型,答案很简单: NSValue条目。 You can have a look at this guide for more info on how to use NSValues . 您可以查看本指南以获取有关如何使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM