このコードを使用して、1 つのグループの線を描画しています。
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];
そして、それはから来る行の1つのグループに対して機能していますが、今ではおそらく次のような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'