使用Google地图和Apple Maps URL计划自动开始导航

JuJ*_*oDi 7 google-maps url-scheme ios apple-maps

在iOS上使用URL方案启动Google地图Apple地图时,有没有办法自动启动导航?

我看到两个可选参数,但没有用户输入就没有开始导航.

Ala*_*eng 4

下面是我的做法,供大家参考,但是对于苹果来说,我还没有找到通过url方案启动导航的方法。

+ (void)navigateToLocation:(CLLocation*)_navLocation {
    if ([[UIApplication sharedApplication] canOpenURL:
         [NSURL URLWithString:@"comgooglemaps://"]]) {
        NSString *string = [NSString stringWithFormat:@"comgooglemaps://?daddr=%f,%f&directionsmode=driving",_navLocation.coordinate.latitude,_navLocation.coordinate.longitude];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
    } else {
        NSString *string = [NSString stringWithFormat:@"http://maps.apple.com/?ll=%f,%f",_navLocation.coordinate.latitude,_navLocation.coordinate.longitude];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
    }
}
Run Code Online (Sandbox Code Playgroud)