【发布时间】:2013-01-29 05:42:43
【问题描述】:
我正在使用这段代码来绘制一组线:
CLLocationCoordinate2D points[[routes count]];
for(int i = 0; i < self.routes.count; i++)
{
CLLocation* location = [self.routes objectAtIndex:i];
points[i] = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate
.longitude);
}
self.routeLine = [MKPolyline polylineWithCoordinates: points count: [routes count]];
[self.mapView setVisibleMapRect: [self.routeLine boundingMapRect] animated: YES];
[self.mapView addOverlay:self.routeLine];
它适用于来自NSArray *routes 的一组行,但现在我需要不止一组行,例如NSMutableArray *routes = { NSArray with routes , NSArray with other group like first example , another array } 可能像这样:
int sumaCount = [a1 count] + [a2 count] + [a3 count];
CLLocationCoordinate2D puntitos[sumaCount];
int c = 0;
for (NSArray *array in rutas)
{
for (CLLocation *cada in array)
{
puntitos[c] = CLLocationCoordinate2DMake(cada.coordinate.latitude, cada.coordinate.longitude);
c++;
}
self.routeLine = [MKPolyline polylineWithCoordinates: puntitos count: sumaCount];
[self.mapView addOverlay: self.routeLine];
}
但我得到了这个例外:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '***
-[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument'
【问题讨论】:
-
您确定显示的代码发生了错误吗?您希望每个组成为单独的叠加层还是应该将它们连接成一条线?
-
好吧@AnnaKarenina,每组线,没有连接,只有那组线。我的意思是,第一组可能是一个多边形,但下一组是正方形,但在 MKMapView 的另一个位置,所以我猜它是另一个叠加层,但是是的,我调试并来自该代码......但没有解释...... .
标签: ios objective-c mkmapview mapkit polyline