I have a mapkit application that puts annotations on a map, when you click on them, it shows a leader with a title attribute.
This works fine, but the user cannot close them. They remain open until they touch another annotation. Can't I make it so that the user can click elsehwere on the map (or touch the annotation again) to close it?
I had the feeling that it was the default setting, so maybe something I do is fill it? I have a gesture recognizer that I use to detect some card taps.
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; tap.numberOfTapsRequired = 1; [self.mapView addGestureRecognizer: tap];
which causes this:
- (void)handleTap:(UITapGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { CGPoint tapPoint = [sender locationInView:sender.view.superview]; CLLocationCoordinate2D coordinate = [self.mapView convertPoint: tapPoint toCoordinateFromView: self.mapView]; if (pitStopMode && !pitStopMade){ pitStopMade = YES; InfoAnnotation *annotation = [[InfoAnnotation alloc] initNewPitstopWithCoordinate:coordinate]; NSLog(@" Created Pit Stop"); annotation.draggable = NO; //place it on the map [self.mapView addAnnotation: annotation]; self.instructionLabel.text = @"Tap button again to remove"; annotation.creatorId = self.localUser.deviceId; //send it to the server [annotation updateLocationWithServerForConvoy: self.convoyCode]; [annotation release]; } if (hazardMode && !hazardMade){ hazardMade = YES; InfoAnnotation *annotation = [[InfoAnnotation alloc] initNewHazardWithCoordinate:coordinate]; NSLog(@" Created Hazard"); annotation.draggable = NO; //place it on the map [self.mapView addAnnotation: annotation]; self.instructionLabel.text = @"Tap button again to remove"; annotation.creatorId = self.localUser.deviceId; //send it to the server [annotation updateLocationWithServerForConvoy: self.convoyCode]; [annotation release]; } }
}
Is there anything I need to do to allow these taps to go to the map? Dragging and listening to annotations works great, although I'm not sure if this causes it?
Is there an option that I am missing, or do I need to try to implement it manually?
source share