I am working on an app that has a list of multiple custom point annotations of places to visit for my partner and I's wedding. I recently figured out how to create a function to open that map. The problem is, when you click on the callout the directions title shows Unknown Location or Nil. I have a title set for all custom point annotations and am just looking for the title of the clicked annotation to be on the map as the end destination title. Any help is much appreciated. This is my first full app and this is the last thing to figure out before getting it up and running. Thanks in advance for your help. Happy to provide more code if the issue isn't coming from this function.
// Open maps app programatically
func mapView(_ mapView: MKMapView, annotationView view:MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let placemark = MKPlacemark(coordinate: view.annotation!.coordinate, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
let launchOptions = [MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeTransit]
view.canShowCallout = true
self.title = title
mapItem.name = title
mapItem.openInMaps(launchOptions: launchOptions)
}