这是我在iOS 10.0 iPhone 6和iOS 11.2 iPhone 6模拟器中设置的自定义位置。
这是我试图打开iPhone内置Apple Map的代码,并显示用户(上面设置)当前位置到指定目的地位置的路线。
let regionDistance: CLLocationDistance = 1000
let coordinates = CLLocationCoordinate2D(latitude: 26.025860999999999, longitude: 56.089238999999999)
let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates, regionDistance, regionDistance)
let options = [MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span),
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving] as [String : Any]
let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = "Federal Electricity & Water Authority"
mapItem.openInMaps(launchOptions: options)
但这根本不起作用。它显示了如下错误,
注意:
MKLaunchOptionsDirectionsModeKey
均未显示
方向。let coordinates = CLLocationCoordinate2D(latitude: 26.025861, longitude: 56.089239)
请帮忙!
答案 0 :(得分:0)