i am trying to naviagate to another page which is my details page for map markers that i have in my map controller view. so for instance if a user clicks on any marker it would take him to that markers details specifically
i created a subclass and initialized the data i need for each marker to be unique.
but now i am facing a problem with how to navigate to the next page since this annotation is not a variable.
here is my code:
my subclass:
class MyAnnotation: MKPointAnnotation{
var shopPID: String!
init(shopPID: String) {
self.shopPID = shopPID
}
}
adding the markers:
db.collection("Shops").getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
let lat = document["latitude"] as? String
let long = document["longitude"] as? String
let myFloat = (lat! as NSString).doubleValue
let myFloat2 = (long! as NSString).doubleValue
let annotation = MyAnnotation(shopPID: document["shopPID"] as! String)
annotation.coordinate = CLLocationCoordinate2D(latitude: myFloat, longitude: myFloat2)
annotation.title = document["name"] as? String
annotation.subtitle = "Click to view shop details"
annotation.shopPID = document["shopPID"] as? String
self.mapView.addAnnotation(annotation)
}
}
}
performing the click events and the segue:
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
print(#function)
if control == view.rightCalloutAccessoryView {
performSegue(withIdentifier: "mapToDetails", sender: nil)
}
}
here is where i have a problem: i need to give a value to the newProjectVC that is stored in the annotations. how would i do that?
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "mapToDetails") {
let navigationController = segue.destination as! UINavigationController
let newProjectVC = navigationController.topViewController as! detailsSectionViewController
newProjectVC.getKey = //variable with each shopPID for each pin should be here
}
}
This circle has my identifier "mapsToDetails"
