2011-11-11 16 views
6

私はMKMapViewを持っています。注釈の周りに円として円を追加する必要があります(例:位置から1km)。注釈の周りに円として円を追加する方法

私はこれがMKAnnotationの何らかの形であると仮定しましたが、これについて説明するドキュメントでは何も見つかりません。誰がこれがどのように行われたか知っていますか?

答えて

14

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; 
} 
+0

半径が何を表しているのでしょうか?メーター? – ThePower

+0

[はい、メートル/メートルを表します。](http://developer.apple.com/library/ios/#DOCUMENTATION/MapKit/Reference/MKCircle_class/Reference/Reference.html#//apple_ref/doc/uid/TP40009710 -CH1-SW3) – Anna

+0

ありがとう:-) – ThePower

関連する問題