Objective-C。如何连接两个 MKPolyline s

Objective-C. How to concatenate two MKPolyline s

我想从另外两个构造一个 MKPolyline。如何在 Objective-C 中做到这一点?

假设第 1 行和第 2 行有一些值。用它们的点创建一个新数组,并使用 MKPolyline 构造函数创建一个新数组。

//MKPolyline *line1, *line2;
    MKMapPoint mapPoints[line1.pointCount + line2.pointCount];
    for(NSUInteger i = 0; i < line1.pointCount + line2.pointCount; i++)
    {
        mapPoints[i] = (i < line1.pointCount) ? line1.points[i] : line2.points[i-line1.pointCount];
    }

    MKPolyline *combinedLine = [MKPolyline polylineWithPoints:mapPoints count:line1.pointCount + line2.pointCount];