2011-07-17 12 views
1

動作しないiPhone - パスを撫でることは...私はMKOverlayViewサブクラスにこれらのメソッドを持っている、と私はなぜ、同じパスが動作しませんなでパスが働く充填し、その理由を理解していない

- (id) init { 
    if (!(self = [super init])) return nil; 

    self.opaque = NO; // If not set, just black squares are drawn 

    return self; 
} 

- (void) drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context { 

    // CGRect rects[2] = {[self rectForMapRect:mapRect], [self rectForMapRect:self.country.boundingMapRect]}; 
    // CGContextClipToRects(context, rects, 2); 

    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0); 
    CGContextSetRGBFillColor(context, 1.0, 0.0, 1.0, 0.9); 
    CGContextSetLineWidth(context, 1.0); 

    for (MKPolygon* poly in self.polygons) { 

     CGPoint origin = [self pointForMapPoint:poly.points[0]];    
     CGContextMoveToPoint(context, origin.x, origin.y); 

     for (int i=1; i<poly.pointCount; i++) { 
      CGPoint point = [self pointForMapPoint:poly.points[i]]; 
      CGContextAddLineToPoint(context, point.x, point.y); 
     } 

     //CGContextFillPath(context); 
     CGContextStrokePath(context); 
    } 
} 


-(BOOL)canDrawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale { 
    return YES; 
} 
+1

あなたは塗りつぶしを移動することができますかループ外のストローク。複数のサブパス( 'moveto' +ラインとカーブのセグメント)を構築し、すべてを一度に塗りつぶしたり、ストロークすることは合法です。 –

答えて

2

ズームアウトの方法は?あなたの脳卒中である可能性があります。それはあまりにも薄いために表示されません。線幅を1.0/zoomScale(または、より一般的にはdesiredLineWidth * (1.0/zoomScale))に設定してみてください。

(免責事項:あなたはそれがあるとしてzoomScaleを使用する必要があるかもしれませんので、私は実際に、MapKitを使ったことがない、ドキュメントの私の読書に基づいて、私は最初1.0/zoomScaleをしようとするだろう)

関連する問題