Manos Chorianopoulos

fix open maps

......@@ -237,19 +237,26 @@ import MapKit
// return
// }
guard let googleMapsUrl = URL(string: "https://www.google.co.in/maps/dir/?saddr=&daddr=\(lat),\(lon)&directionsmode=driving"),
let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") else {
// guard let googleMapsUrl = URL(string: "https://www.google.co.in/maps/dir/?saddr=&daddr=\(lat),\(lon)&directionsmode=driving"),
// let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") else {
// print("Error creating URLs")
// return
// }
//
// // check if link can be opened with google maps.
// guard UIApplication.shared.canOpenURL(googleMapsUrl) else {
// UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil)
// return
// }
//
// UIApplication.shared.open(googleMapsUrl, options: [:], completionHandler: nil)
guard let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") else {
print("Error creating URLs")
return
}
// check if link can be opened with google maps.
guard UIApplication.shared.canOpenURL(googleMapsUrl) else {
UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil)
return
}
UIApplication.shared.open(googleMapsUrl, options: [:], completionHandler: nil)
}
......