after doing a lot of research I found a solution for this! It's a tiny tiny bit hacky, but it works like a charm.
The secret is, that when turning off zoom for the map, the didSelect listener triggers immediately. As we need zoom (of course), what we need to do is, to temporarily disable the zoom, just for the moment of the didSelect event!
In Swift:
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
gestureRecognizer.numberOfTapsRequired = 1
gestureRecognizer.numberOfTouchesRequired = 1
gestureRecognizer.delegate = self
mapView.addGestureRecognizer(gestureRecognizer)
and
@objc func handleTap(_ sender: UITapGestureRecognizer? = nil) {
// disabling zoom, so the didSelect triggers immediately
mapView.isZoomEnabled = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.mapView.isZoomEnabled = true
}
}
This gesture event triggers before the didSelect event. So the moment the didSelect events is called, zoom is turned off and it does trigger without delay!
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
mapView.isZoomEnabled = true // Not really necessary
// Triggered immediately, do something
}
Note: This disables doubleTap gestures for the map, but I guess they are not used too much. So if you want a quick response, you need to live with it!