मार्ग-Me कैसे, उदाहरण के लिए नक्शे पर एक पथ आकर्षित करने के लिए वास्तव में नहीं है, लेकिन करीब (आपके मामले में आप सब मार्ग अंक जोड़ने के लिए)।
उपयोग RMPath ओवरले परत पर एक बहुभुज बनाने के लिए
//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;
}
नोट:
नवीनतम RouteMe addLineToCoordinate हैं: (CLLocationCoordinate2D) addLineToLatLong के बजाय समन्वय।
यह नया है एक मार्ग-मुझ में
- (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;
}
उदाहरण में MapTestBed में पाया
स्रोत
2012-05-14 05:30:39