I want to leave this solution here for anyone trying to add the pin and show the actual place card with name and details (instead of just a pin with coordinates):
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
let encodedName = self.location.name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? ""
let googleMapsURL = "comgooglemaps://?q=\(encodedName)¢er=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)&views=satellite&zoom=15"
UIApplication.shared.open(URL(string: googleMapsURL)!, options: [:], completionHandler: nil)
} else {
print("Can't use comgooglemaps://")
}
This works perfectly if there's only one place with that specific name. Unfortunately, if there are multiple places with the same name (like if there's a bus station right next to your location), it will show a list of all matching places. I haven't found a way to only get the wanted place, even if I use it's ID.
Note: This solution requires the place name (location.name) in addition to the coordinates.
If anyone has a better solution that can handle multiple places with the same name, please share it in the comments as I'm also looking for one!