Search code examples
iosios6mkmapviewmkoverlay

Custom map path line


I'm having trouble with drawing a line on the map with a stroke. (inside color and outside color) I beleive i'm on the right path and have subclassed mkOverlayView to override the drawing (needs to fill with the road size) so inside drawMapRect...

CGFloat lineWidth = MKRoadWidthAtZoomScale(zoomScale);

MKMapRect clipRect = MKMapRectInset(mapRect, -lineWidth, -lineWidth);

  ...

CGContextAddPath(context, path);
CGContextSetStrokeColorWithColor(context, line.color.CGColor);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, lineWidth);
CGContextSetAlpha(context, 0.4f);
CGContextStrokePath(context);

CGPathRelease(path);

I'm not sure how to add the stroke. Any help would be greatly appreciated. xcode 4.6 / ios 6.0+

enter image description here


Solution

  • stroke first a path ( road with) with color 1, then change stroke width and color to a thinner line with road with * 0.6 in color 2, and stroke again.