每当用户点击 时MKPointAnnotation
,我希望他被重定向到特定视图。我的问题是如何让注释在点击时执行操作?
这是我的代码:
for i in closestpharmacyname {
var docref2 = db.collection("pharmacies").document(i)
print("Pharmacy: ", i)
docref2.getDocument(source: .cache) { (document, error) in
if var document = document {
var pharmacylatitude = document.get("latitude") as! Double
var pharmacylongitude = document.get("longitude") as! Double
print(pharmacylatitude, pharmacylongitude)
var pharmacyannotation = MKPointAnnotation()
pharmacyannotation.coordinate = CLLocationCoordinate2D(latitude: pharmacylatitude, longitude: pharmacylongitude)
pharmacyannotation.title = i
self.MapView.addAnnotation(pharmacyannotation)
} else{
print("Document Does not exist")
}
}
}