问题描述
我在苹果地图中提供源地址和目的地地址,如果使用苹果地图找不到目的地的方向,是否可以选择将源地址作为用户位置。
if UIApplication.shared.canOpenURL(appleMapURL!) {
let sourceCoordinate = CLLocationCoordinate2DMake(latitude,longitude)
let placeMark = MKPlacemark(coordinate: sourceCoordinate,addressDictionary: nil)
let sourceCoordinateMapItem = MKMapItem(placemark: placeMark)
sourceCoordinateMapItem.name = "My Place"
let destinationCoordinate = CLLocationCoordinate2DMake(destinationLatitude,destinationLongitude)
let destinationPlaceMark = MKPlacemark(coordinate: destinationCoordinate,addressDictionary: nil)
let desinationLocationMapItem = MKMapItem(placemark: destinationPlaceMark)
desinationLocationMapItem.name = "Destination"
let mapArray = [sourceCoordinateMapItem,desinationLocationMapItem]
let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving]
MKMapItem.openMaps(with: mapArray,launchOptions: launchOptions)
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)