1

MapKit フレームワークを使い始めたばかりで、最初の練習はうまくいきませんでした :)

海のどこかを示す MapView を除いて、すべてが正常に機能しているように見え、場所が見つかりませんでした (例: 土地、島)。緯度と経度がなぜか範囲外になっていると思います。

ここに私のコードがあります:

    - (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIBarButtonItem *zoomButton =
    [[UIBarButtonItem alloc]
     initWithTitle: @"Zoom-In"
     style:UIBarButtonItemStyleBordered
     target: self
     action:@selector(zoomIn:)];

    UIBarButtonItem *typeButton =
    [[UIBarButtonItem alloc]
     initWithTitle: @"Zoom-Out"
     style:UIBarButtonItemStyleBordered
     target: self
     action:@selector(zoomOut:)];

    NSArray *buttons = [[NSArray alloc]
                        initWithObjects:zoomButton, typeButton, nil];

    barButtons.items = buttons;



    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);

    MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];

    zoomLocation.latitude = 48.431638;
    zoomLocation.longitude= 27.169436;
    annotationPoint.coordinate = zoomLocation;
    annotationPoint.title = @"My Company";
    annotationPoint.subtitle = @"my Company Title";


    //[self __mapView];

    MKCoordinateRegion adjustedRegion = [__mapView regionThatFits:viewRegion];

    [__mapView setRegion:adjustedRegion animated:YES];

    [__mapView addAnnotation:annotationPoint];
}
4

1 に答える 1

2

zoomLocation領域を作成した後に座標を設定しています。まずは設定してみるzoomLocation

...
zoomLocation.latitude = 48.431638;
zoomLocation.longitude= 27.169436;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
...
于 2013-03-18T15:22:01.407 に答える