有没有办法在启动时自动启动导航Google Maps或 Apple 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/