在iOS上使用URL方案启动
Google Maps或
Apple Maps时,有没有办法自动启动导航?
我看到两个可选参数,但没有用户输入就没有开始导航.
解决方法
这是我如何为你的参考,但对于苹果,我还没有找到一种方法来启动通过网址方案导航.
+ (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.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
}
}