2012-09-15 81 views
1

我试图为一个MapView的覆盖视图添加笔触和填充路径。现在填充工程,笔画不...从任何想法看下面的代码?MKMapView - 抚摸一条路径

- (void)drawMapRect:(MKMapRect)mapRect 
      zoomScale:(MKZoomScale)zoomScale 
      inContext:(CGContextRef)ctx 
{  
    CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 0.8); 
    CGContextSetRGBFillColor(ctx, 0.0, 0.0, 0.8, 0.4); 

    CGContextSetLineCap(ctx, kCGLineCapRound); 
    CGContextSetLineWidth(ctx, 8.0); 

    CGPoint pt; 
    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(0, 0))]; 
    CGContextMoveToPoint(ctx, pt.x, pt.y); 

    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(-2, 3))]; 
    CGContextAddLineToPoint(ctx, pt.x, pt.y); 

    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(-2, 5))]; 
    CGContextAddLineToPoint(ctx, pt.x, pt.y); 

    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(-4, 4))]; 
    CGContextAddLineToPoint(ctx, pt.x, pt.y); 

    CGContextDrawPath(ctx, kCGPathFillStroke); 
} 

回答

1

这使得工作...

CGContextSetLineWidth(ctx, 1 * MKRoadWidthAtZoomScale(zoomScale));