Этот код проверит, установлены ли карты Google. Если да, это откроет местоположение в картах, иначе откроет местоположение в сафари.
fun c mapView (_ mapView: GMSMapView, didTapAt координата: CLLocationCoordinate2D) {
if(self.current_long != "" && self.current_lat != "")
{
//Add your latitude
let lat: String = self.current_lat
//Add your longitude
let lon: String = self.current_long
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.open(URL(string:"comgooglemaps://?center=\(lat),\(lon)&zoom=14&views=traffic&q=\(lat),\(lon)")!, options: [:], completionHandler: nil)
}else{
print("Cannot open maps")
if let urlDestination = URL.init(string: "https://www.google.com/maps/?center=\(lat),\(lon)&zoom=14&views=traffic&q=\(lat),\(lon)"){
UIApplication.shared.open(urlDestination, options: [:], completionHandler: nil)
}
}
}
}