MapGuideManager.guide(from: nil, to:job.gps.location, with: job.companyName)
class MapGuideManager {
class func guide(from startPoint: CLLocationCoordinate2D? = nil, to destination: CLLocationCoordinate2D? = nil, with destinationTitle: String) {
guard let startPoint = startPoint else {
let destinationMark = MKPlacemark(coordinate: destination!)
let destinationItem = MKMapItem(placemark: destinationMark)
destinationItem.name = destinationTitle
let mapItems = [destinationItem]
let dic: [String: AnyObject] = [
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeTransit as AnyObject,
MKLaunchOptionsMapTypeKey: MKMapType.standard.rawValue as AnyObject,
MKLaunchOptionsShowsTrafficKey: true as AnyObject
]
MKMapItem.openMaps(with: mapItems, launchOptions: dic)
return
}
let startPointMark = MKPlacemark(coordinate: startPoint)
let startPointItem = MKMapItem(placemark: startPointMark)
startPointItem.name = "現在位置"
let destinationMark = MKPlacemark(coordinate: destination!)
let destinationItem = MKMapItem(placemark: destinationMark)
destinationItem.name = destinationTitle
let mapItems = [startPointItem, destinationItem]
let dic: [String: AnyObject] = [
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeTransit as AnyObject,
MKLaunchOptionsMapTypeKey: MKMapType.standard.rawValue as AnyObject,
MKLaunchOptionsShowsTrafficKey: true as AnyObject
]
MKMapItem.openMaps(with: mapItems, launchOptions: dic)
}
}