簡體   English   中英

如何創建CLLocationCoordinate2d對象

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM