ios - 使用 Google map 和 Apple map URL 方案自动开始导航

标签 ios google-maps url-scheme apple-maps

有没有办法在启动时自动启动导航Google MapsApple Maps在 iOS 上使用 URL Scheme?

我看到了两个的几个可选参数,但没有一个可以在没有用户输入的情况下开始导航。

最佳答案

我是这样实现的,供大家引用,但是对于apple,我还没有找到通过url scheme启动导航的方法。

+ (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]];
    }
}

关于ios - 使用 Google map 和 Apple map URL 方案自动开始导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26039724/

相关文章:

ios - 自定义 UITableViewCell 在编辑时不显示缩进

javascript - Google map 使用 php 和 jquery 动态显示许多标记

ios - 使用 URL 方案在应用程序内部导航

ios - Google map URL 方案不适用于 iOS 9

ios - 向核心数据中的托管对象发出加载子实体

ios - 在滚动到顶部的 UITextView 上检测向下滑动

ios - 针对 iOS5 - 它也适用于 iOS6 吗?

javascript - 谷歌地图移动 View

javascript - jQuery 值未按预期从 ipinfo 分配

html - 如何从网站上的链接打开 native iOS 应用程序(日历、笔记...)?