0

組み込みのマップアプリケーションを開く代わりに、iOS 6のMKMapView内にナビゲーションルートを作成できるかどうか疑問に思いましたか?
グーグルで検索しましたが、答えが見つかりませんでした。

これは私が現在使用しているコードです(つまり、組み込みのマップアプリを開いています)。

-(IBAction) navigation
{
    if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
    {
        NSString *destinationString = @"Afek, Israel";
        NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",wedMapView.userLocation.coordinate.latitude,wedMapView.userLocation.coordinate.longitude, destinationString];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    }

    else
    {
        Class mapItemClass = [MKMapItem class];
        if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
        {
            double latitude = 32.83431728836292;
            double longitude = 35.128666162490845;
            MKPlacemark *placemark = [[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) addressDictionary:nil] autorelease];
            //[mapItem setName:@"Name of your location"];

            // Create a map item for the geocoded address to pass to Maps app
            MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
            [mapItem setName:@"שמורתה, קיבוץ אפק"];

            // Set the directions mode to "Driving"
            // Can use MKLaunchOptionsDirectionsModeWalking instead
            NSDictionary *launchOptions = @{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving};

            // Get the "Current User Location" MKMapItem
            MKMapItem *currentLocationMapItem = [MKMapItem mapItemForCurrentLocation];

            // Pass the current location and destination map items to the Maps app
            // Set the direction mode in the launchOptions dictionary
            [MKMapItem openMapsWithItems:@[currentLocationMapItem, mapItem] launchOptions:launchOptions];
        };
    }
}  

そしてこれは私が持っているMKMapViewです私が青い地図ボタン(Wazeボタンの上)を押したときにターンバイターン方式で作りたいです:

MKMapView

助けてくれてありがとう。

4

1 に答える 1

1

iOS 6はアプリに道順を提供しません、それは組み込みのマップアプリに依存しています。そのため、アプリでルートを表示する場合は、ルートを計算するためのサービスを見つける必要があります。Googleは、Appleのデータではなく、マップでのみデータを使用できるため、Googleを使用することはできません。CloudMadeとOpenStreetMapを調べることもできますが、そのためにiOS6のマップを使用することを諦める必要があります。オープンUIコンポーネントが付属しています。

于 2012-12-09T18:38:16.873 に答える