How to add circle as radius around annotation

I have MKMapView. I need to add a circle as a radius around the annotation (say 1 km from the position).

I would suggest that this is some form of MKAnnotation, but I cannot find anything in the documentation that explains this. Does anyone know how to do this?

+6
source share
1 answer

You need to create an MKCircle overlay and set its center coordinate in the same way as the annotation.

For instance:

 //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; } 
+14
source

Source: https://habr.com/ru/post/901273/


All Articles