3

ルートを取得する簡単な方法を見つけたいと思います。これを行う方法はありますmapviewか?以下は私の現在のコードです。

- (IBAction)goToMap:(id)sender {

[self.view addSubview:self.mapUIView];
[self.mapUIView setFrame:CGRectMake(0, 0, 320, 460)];

self.mapview.mapType = MKMapTypeStandard;

CLLocationCoordinate2D coordinate;
coordinate.latitude = [[self.find lat] floatValue];
coordinate.longitude = [[self.find lng] floatValue];
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];

[annotation setCoordinate:coordinate];
[annotation setTitle:[self.find name]];
//[annotation setSubtitle:@"Hello"];
[self.mapview addAnnotation:annotation];
[annotation release];

[self zoomMapViewToFitAnnotations:self.mapview animated:YES];

 }
4

4 に答える 4

0

方向をプロットする場合は、 https ://github.com/kishikawakatsumi/MapKit-Route-Directionsを使用します。

于 2012-10-22T12:51:33.653 に答える
0
CLLocationManager *manager = [[CLLocationManager alloc] init] ;
    CLLocationCoordinate2D currentLocation = [manager location].coordinate;
    CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(37.365502,-94.394531);
    NSString *fromLocation = [NSString stringWithFormat: @"%f,%f",
                      currentLocation.latitude, currentLocation.longitude];
    NSString *toLocation = [NSString stringWithFormat: @"%f,%f",
                                Coordinate.latitude, Coordinate.longitude];
    NSString *url = [NSString stringWithFormat:
                     @"http://maps.google.com/maps?saddr=%@&daddr=%@", fromLocation, fromLocation];

    UIWebView *webView = [[UIWebView alloc]init];
    NSURL *targetURL = [NSURL URLWithString:url];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [webView loadRequest:request];
于 2013-04-19T13:10:02.507 に答える
0

ルート案内に MapKit を使用することはできません。これはサポートされていません。

于 2012-10-22T12:16:13.283 に答える
0

デバイスの現在の位置を表示したい場合 (運転中など)、プロジェクトに CoreLocation フレームワークを追加する必要があり、現在の位置を取得するために「updateLocation」メソッドを使用する必要がありますが、2 つの位置の間のパスを描画する場合は、使用する必要がありますこのための Google API。

于 2012-10-22T12:30:13.633 に答える