Ruta-Me cómo dibujar un recorrido sobre el mapa, por ejemplo, no exactamente, pero cerca.
Uso RMPath dibujar un polígono en la capa de superposición
//polygonArray is a NSMutableArray of CLLocation
- (RMPath*)addLayerForPolygon:(NSMutableArray*)polygonArray toMap:(RMMapView*)map {
RMPath* polygonPath = [[[RMPath alloc] initForMap:map] autorelease];
[polygonPath setLineColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.5]];
[polygonPath setFillColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.5]];
[polygonPath setLineWidth:1];
BOOL firstPoint = YES;
for (CLLocation* loc in polygonArray) {
if (firstPoint) {
[polygonPath moveToLatLong:loc.coordinate];
firstPoint = NO;
} else {
[polygonPath addLineToLatLong:loc.coordinate];
}
}
[polygonPath closePath];
polygonPath.zPosition = -2.0f;
NSMutableArray *sublayers = [[[[mapView contents] overlay] sublayers] mutableCopy];
[sublayers insertObject:polygonPath atIndex:0];
[[[mapView contents] overlay] setSublayers:sublayers];
return polygonPath;
}
Nota:
La última RouteMe tiene addLineToCoordinate: (CLLocationCoordinate2D) en lugar de coordinar addLineToLatLong.
Esto es más reciente que se encuentra en el MapTestBed en el ejemplo de la Ruta-me
- (RMMapLayer *)mapView:(RMMapView *)aMapView layerForAnnotation:(RMAnnotation *)annotation
{
if ([annotation.annotationType isEqualToString:@"path"]) {
RMPath *testPath = [[[RMPath alloc] initWithView:aMapView] autorelease];
[testPath setLineColor:[annotation.userInfo objectForKey:@"lineColor"]];
[testPath setFillColor:[annotation.userInfo objectForKey:@"fillColor"]];
[testPath setLineWidth:[[annotation.userInfo objectForKey:@"lineWidth"] floatValue]];
CGPathDrawingMode drawingMode = kCGPathStroke;
if ([annotation.userInfo containsObject:@"pathDrawingMode"])
drawingMode = [[annotation.userInfo objectForKey:@"pathDrawingMode"] intValue];
[testPath setDrawingMode:drawingMode];
if ([[annotation.userInfo objectForKey:@"closePath"] boolValue])
[testPath closePath];
for (CLLocation *location in [annotation.userInfo objectForKey:@"linePoints"])
{
[testPath addLineToCoordinate:location.coordinate];
}
return testPath;
}
if ([annotation.annotationType isEqualToString:@"marker"]) {
return [[[RMMarker alloc] initWithUIImage:annotation.annotationIcon anchorPoint:annotation.anchorPoint] autorelease];
}
return nil;
}