I am using UIMapView to display locations on the iPhone. I want to do a directions from current location to the location of interest, I don\'t think its possible using MapKi
Use bellow code for both google and apple maps in Swift 3 -
if UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!)
{
let urlString = "http://maps.google.com/?daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&directionsmode=driving"
// use bellow line for specific source location
//let urlString = "http://maps.google.com/?saddr=\(sourceLocation.latitude),\(sourceLocation.longitude)&daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&directionsmode=driving"
UIApplication.shared.openURL(URL(string: urlString)!)
}
else
{
//let urlString = "http://maps.apple.com/maps?saddr=\(sourceLocation.latitude),\(sourceLocation.longitude)&daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&dirflg=d"
let urlString = "http://maps.apple.com/maps?daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&dirflg=d"
UIApplication.shared.openURL(URL(string: urlString)!)
}