ストーリーボードを使用して、View Controller でマップ ビューを作成しています。
次のコードを使用すると。
-(void) mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
CLLocationDistance distance = 1000;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate,
distance,
distance);
MKCoordinateRegion adjusted_region = [self.mapView regionThatFits:region];
[self.mapView setRegion:adjusted_region animated:YES];
}
ポイントは、米国カリフォルニア州サンフランシスコにプロットされています。userLocation
座標は、フレームワークで定義済みの値です
MapKit.h
。今私は作成します
-(void) mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
CLLocationDistance distance = 1000;
CLLocationCoordinate2D myCoordinate;
myCoordinate.latitude = 13.04016;
myCoordinate.longitude = 80.243044;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(myCoordinate,
distance,
distance);
MKCoordinateRegion adjusted_region = [self.mapView regionThatFits:region];
[self.mapView setRegion:adjusted_region animated:YES];
}
ここでは、座標を中心に領域を表示する。ただし、座標位置に点はプロットされません。
その座標位置にポイントまたは注釈をプロットする方法は?