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

时间:2015-06-08 13:53:01

标签: objective-c mapkit

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

1 个答案:

答案 0 :(得分:1)

假设line1和line2有一些值。使用它们的点创建一个新数组,并使用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];