3

iOS の既定のマップ アプリで 2 つの場所の間の方向を取得する機能を実装したいのですが、これを試しました

Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
    // Use iOS 6 maps
    NSString *latString = @"23.0300";
    NSString *longString = @"72.5800";

    CLLocationCoordinate2D  ctrpoint;
    ctrpoint.latitude = [latString doubleValue];
    ctrpoint.longitude = [longString doubleValue];

    MKPlacemark *placemark2 = [[MKPlacemark alloc] initWithCoordinate:ctrpoint addressDictionary:nil];
    MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark2];
    [mapItem openInMapsWithLaunchOptions:nil];
}

ただし、以下のように方向エラーが表示されます。

方向エラーの取得

地図アプリを開いて、現在地を特定し、現在地に最も近い地図にピンを 1 つ追加しましたが、それでも方向を取得できません。

また、「要するに、ネイティブアプリでもGet Directionが完全に機能していません」これを達成するのを手伝ってくれる人はいますか?

4

2 に答える 2

7

Apple Maps は、インドのルート案内をサポートしていません。

電話で利用できる場合は、道案内に Google マップを使用できます。Google マップ アプリが利用できない場合は、Apple マップに頼ってください。

次のコード ブロックが役立つ場合があります。

    NSURL *appUrl;

    //Is Google Maps App Installed ?
   if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {

        // Use Google Maps App to get Directions
       appUrl = [NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?daddr=%f,%f&saddr=%f,%f",
                            destLocation.coordinate.latitude, destLocation.coordinate.longitude,
                            _currentLocation.coordinate.latitude,_currentLocation.coordinate.longitude]];
    }

    // Google Maps not Installed
    else {

        // Use Apple Maps App to get Directions
        appUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.apple.com/?daddr=%f,%f&saddr=%f,%f",
                           destLocation.coordinate.latitude, destLocation.coordinate.longitude,
                           _currentLocation.coordinate.latitude,_currentLocation.coordinate.longitude]];
    }

    [[UIApplication sharedApplication] openURL:appUrl];
于 2013-11-01T07:44:31.850 に答える
1

このApple 機能の可用性によると、ルート案内はインドではサポートされていません。

この投稿によると、同じことが iOS 6 にも当てはまるようです。

于 2013-10-31T10:59:29.963 に答える