Вам нужно написать аннотации класса
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface Annotation : NSObject <MKAnnotation>
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (strong, nonatomic) NSString *myTitle;
+ (Annotation *)initAnnotation:(CLLocationCoordinate2D)coordinate title:(NSString *)title;
@end
Реализация
#import "Annotation.h"
@implementation Annotation
+ (Annotation *)initAnnotation:(CLLocationCoordinate2D)coordinate title:(NSString *)title
{
return [[Annotation alloc] initWithAnnotation:coordinate title:title];
}
- (instancetype)initWithAnnotation:(CLLocationCoordinate2D)coordinate title:(NSString *)title
{
self = [super init];
self.coordinate = coordinate;
self.myTitle = title;
return self;
}
@end
ViewController
#import "ViewController.h"
#import <MapKit/MapKit.h>
#import "Annotation.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//set coordinates
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(51.50851, -0.02172);
//add annotation
Annotation *annotation = [Annotation initAnnotation:coordinate title:@"Annotation"];
[self.mapView addAnnotation:annotation];
[self.mapView showAnnotations:@[annotation] animated:YES];
// add circle with radius
MKCircle *circle = [MKCircle circleWithCenterCoordinate:annotation.coordinate radius:10000];
[self.mapView addOverlay:circle];
//add region by coordinates
MKCoordinateRegion region;
region.center.latitude = 51.50851;
region.center.longitude = -0.02172;
// level zoom
region.span.latitudeDelta = 1;
region.span.longitudeDelta = 1;
region = [self.mapView regionThatFits:region];
[self.mapView setRegion:region animated:YES];
}
Не забудьте установить контроллер в качестве делегата карты,и реализуйте метод отображения окружности
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>) overlay{
MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
circleView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.4];
return circleView;
}[![enter image description here][1]][1]
Появляется пин-код, и вы можете настроить его размер
https://prntscr.com/lvfjwi