在我的 mapView 应用程序中,我正在尝试进行注释,在不添加注释的情况下,我得到了 mapView,但是当我尝试添加注释时,只有注释标记可见,地图变得不可见。
添加注解之前:
代码:
[super viewDidLoad];
mapView = [[MKMapView alloc]initWithFrame:CGRectMake(0, 0, 320, elf.view.frame.size.height)];
mapView.showsUserLocation = YES;
mapView.mapType = MKMapTypeStandard;
mapView.delegate = self;
[self.view addSubview:mapView];
图片:
添加注释后:
代码:
[super viewDidLoad];
mapView = [[MKMapView alloc]initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height)];
mapView.showsUserLocation = YES;
mapView.mapType = MKMapTypeStandard;
mapView.delegate = self;
[self.view addSubview:mapView];
MKUserLocation *userLocation = mapView.userLocation;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 20, 20);
[mapView setRegion:region];
MKPointAnnotation *annotation = [[MKPointAnnotation alloc]init];
annotation.coordinate = userLocation.location.coordinate;
annotation.title = @"Here you r";
annotation.subtitle = @"Pondy";
[mapView addAnnotation:annotation];
图片:
我需要注释出现在地图中。提前致谢。