I have a MKMapView with some MKPolygons and a few Custom Annotations. When ill try to tap on a Annotation Inside a MKPolygon, the trigger for the polygon always gets fired.
Can i prevent this? Ill already check on Polygon tap:
func handleMapTap(tap: UITapGestureRecognizer!) {
var tapPoint = tap.locationInView(self.mapView)
var tapCoord: CLLocationCoordinate2D = self.mapView.convertPoint(tapPoint, toCoordinateFromView: self.mapView)
var mapPoint: MKMapPoint = MKMapPointForCoordinate(tapCoord)
var mapPointAsCGP: CGPoint = CGPointMake(CGFloat(mapPoint.x),CGFloat(mapPoint.y))
for overlay in self.mapView.overlays {
if(overlay.isKindOfClass(MKPolygon)) {
This is how it looks like:
Any ideas? Can i make a "Larger" Area for an annotion, so i do not fire both events, for the Annotation AND the MKPolygon?
Edit: Thanks Anna,
ill tried that, but it brings me an "found nil while unwrapping an Optional value" error when ill try with:
var v:UIView = mapView.hitTest(mapPointAsCGP, withEvent: nil)! // error
if(v.isKindOfClass(CustomPointAnnotation) == true) {