【发布时间】:2011-11-11 03:59:53
【问题描述】:
我有一个 MKMapView。我需要在注释周围添加一个圆作为半径(比如距离该位置 1 公里)。
我会假设这是某种形式的 MKAnnotation,但我在文档中找不到任何解释这一点的内容。有谁知道这是怎么做到的?
【问题讨论】:
标签: iphone objective-c xcode sdk
我有一个 MKMapView。我需要在注释周围添加一个圆作为半径(比如距离该位置 1 公里)。
我会假设这是某种形式的 MKAnnotation,但我在文档中找不到任何解释这一点的内容。有谁知道这是怎么做到的?
【问题讨论】:
标签: iphone objective-c xcode sdk
您需要创建一个MKCircle 叠加层并将其中心坐标设置为与注释相同。
例如:
//after adding the annotation at "coordinate", add the circle...
MKCircle *circle = [MKCircle circleWithCenterCoordinate:coordinate radius:1000];
[mapView addOverlay:circle];
//implement the viewForOverlay delegate method...
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay
{
MKCircleView *circleView = [[[MKCircleView alloc] initWithOverlay:overlay] autorelease];
circleView.strokeColor = [UIColor redColor];
circleView.lineWidth = 2;
return circleView;
}
【讨论】: