Мне нужно отобразить MKOverlay на карте, но я не могу его отобразить.
Я следую примеру из Руководства по программированию Apple и наложения не отображаются. Буду признателен за любую помощь, это первое приложение для iPhone, которое я сделал, поэтому я могу упустить что-то простое.
NavViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface NavViewController : UIViewController <MKMapViewDelegate> {
}
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
NavViewController.m
#import "MSUNavViewController.h"
#import <CoreLocation/CoreLocation.h>
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKPolygon class]])
{
MKPolygonView* aView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon*)overlay];
aView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:0.2];
aView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];
aView.lineWidth = 3;
return aView;
}
return nil;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Define an overlay that covers Colorado.
CLLocationCoordinate2D points[4];
points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116);
points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066);
points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981);
points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267);
MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:4];
poly.title = @"Colorado";
[_mapView addOverlay:poly];
}
Раскадровка:
![storyboard](https://i.stack.imgur.com/g53Eb.png)
Буду очень признателен за любые предложения по кодированию.
Спасибо!