1

現在の場所と1つのMkPointAnnotationを持つMapKitがあります。これらのポイント間のルートをトレースする必要があります。

- (void)viewDidLoad
{
    [super viewDidLoad];

    //esconder navBar
    [[self navigationController] setNavigationBarHidden:YES animated:NO];

    mapView.showsUserLocation = YES;
    UIBarButtonItem *zoomButton = [[UIBarButtonItem alloc] 
                                   initWithTitle: @"Onde Estou?"
                                   style:UIBarButtonItemStylePlain
                                   target: self
                                   action:@selector(zoomIn:)];

    self.navigationItem.rightBarButtonItem = zoomButton;

    UIBarButtonItem *typeButton = [[UIBarButtonItem alloc] 
                                   initWithTitle: @"Tipo"
                                   style:UIBarButtonItemStylePlain
                                   target: self
                                   action:@selector(changeMapType:)];

    self.navigationItem.leftBarButtonItem = typeButton;

    double lat = -21.21258;
    double lng = -47.816802;

    CLLocationCoordinate2D Coordinate;

    Coordinate.latitude = lat;
    Coordinate.longitude = lng;

    MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
    annotationPoint.coordinate = Coordinate;
    annotationPoint.title = @"Ribeirão Shopping";
    annotationPoint.subtitle = @"Ribeirão Preto - SP";
    [self.mapView addAnnotation:annotationPoint]; 

    MKCoordinateRegion newRegion;
    newRegion.center.latitude = lat;
    newRegion.center.longitude = lng;
    [self.mapView setRegion:newRegion animated:YES];

    mapView.mapType = MKMapTypeStandard;


}
4

2 に答える 2

0

MKDirectionReqeuest と MKDriectionResponse を使用します。MKDirectionResponse には、線をプロットするのに役立つ MKRoute があります。

ドキュメントはここにあります ( https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKDirectionsRequest_class/ )

于 2016-01-28T01:35:00.667 に答える
0

これはネイティブ API では不可能です。JSON を介して、Googleルート案内が提供する HTTP サービスを使用できます。

于 2012-08-16T20:01:22.037 に答える