ユーザーの現在の場所にズームインするMapViewをアプリで作成しましたが、これは完全に機能します。以下の私のコードを参照してください:
.hファイル
@interface MapViewController : UIViewController <MKMapViewDelegate>
@property (nonatomic, strong) IBOutlet MKMapView *mapView;
@end
.mファイル
- (void)viewDidLoad {
[super viewDidUnload];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
self.mapView.delegate = self;
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = userLocation.coordinate;
point.title = @"You Are Here";
point.subtitle = @"Your current location";
[self.mapView addAnnotation:point];
}
このコードは、ユーザーの現在の場所に注釈を配置します。ただし、ここから、複数の注釈を追加したいと思います(ユーザーがそれらの周りの重要な場所を確認できるようにするため)。これを行うには、どのコードを追加/変更する必要がありますか?
ありがとう。