我正在使用通用链接打开我的Apple地图应用程序。
我实施它们以打开具有不同运输类型的应用程序(通过汽车,步行和公共交通)。我也想打开它并将用户的视图集中在服务选项卡上,但无法找到方法。
任何的想法 ?我提前感谢你的时间和回应!最好的祝福,
你可以使用launchOptions
在MKLaunchOptionsDirectionsModeKey
中设置它,但它目前只支持:
MKLaunchOptionsDirectionsModeDriving
MKLaunchOptionsDirectionsModeWalking
MKLaunchOptionsDirectionsModeTransit
MKLaunchOptionsDirectionsModeDefault //Users current preference
没有选项(Swift 4.2)来选择最后一个选项卡(用于Ride / Services)。这可能是因为这是最近添加的功能,Apple尚未更新该课程。我不知道一个解决方法。
https://developer.apple.com/documentation/mapkit/mkmapitem/directions_mode_values
为了完整起见,这就是你打开它的方式:
let coordinate = CLLocationCoordinate2DMake(37.331686, -122.030656)
let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate))
mapItem.openInMaps(launchOptions: [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeTransit])