如何将MKCircle的半径(以米为单位)转换为可以在MKOverlayPathView子类中使用核心图形绘制圆的值?
在下面的代码中,半径被硬编码为50,但我需要它来反映MKCircle的半径。
对于位置,我使用MKMapPointForCoordinate()将MKCircle的坐标转换为MKMapPoint,然后使用MKOverlayPathView的pointForMapPoint:将MKMapPoint转换为一个点。但是如何将MKCircle的半径转换为相对距离呢?
MKCircle *circle = [self circleForLocation:location];
CGPoint relativePoint = [self pointForMapPoint:MKMapPointForCoordinate(circle.coordinate)];
float radius = 50;
//Fill
[self applyFillPropertiesToContext:context atZoomScale:zoomScale];
CGContextAddArc(context, relativePoint.x, relativePoint.y, radius, 0, 2*3.1415926535898, 1);
CGContextDrawPath(context, kCGPathFill);发布于 2011-11-28 03:46:03
MKCircle的boundingMapRect的高度和宽度应该等于圆的直径:
CGRect boundingRect = [self rectForMapRect:circle.boundingMapRect];
CGFloat radius = boundingRect.size.width / 2;https://stackoverflow.com/questions/8288093
复制相似问题