【问题标题】:How add a circle as a radius around annotation如何在注释周围添加一个圆作为半径
【发布时间】:2011-11-11 03:59:53
【问题描述】:

我有一个 MKMapView。我需要在注释周围添加一个圆作为半径(比如距离该位置 1 公里)。

我会假设这是某种形式的 MKAnnotation,但我在文档中找不到任何解释这一点的内容。有谁知道这是怎么做到的?

【问题讨论】:

    标签: iphone objective-c xcode sdk


    【解决方案1】:

    您需要创建一个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;
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-20
    • 2011-01-31
    • 1970-01-01
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 2021-10-17
    • 2012-12-24
    相关资源
    最近更新 更多