user1722889
user1722889

Reputation:

Hide SKAnnotationView if user clicks anywhere else in the map view

I am implementing SKMapView in my project. There I am showing user few annotations. On clicking I am displaying a UIView with some relevant information about those coordinates. Now if user clicks anywhere else in the map area. I want to hide this marker info view. I am capturing map click using below method

-(void)mapView:(SKMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate.

This is how I am showing annotation in my view

//create the SKAnnotationView
SKAnnotationView *view = [[SKAnnotationView alloc] initWithView:pinView reuseIdentifier:@"viewID"];

//create the annotation
SKAnnotation *viewAnnotation = [SKAnnotation annotation];

//set the custom view
viewAnnotation.annotationType = SKAnnotationTypePurple;
viewAnnotation.annotationView = view;
viewAnnotation.identifier = index;
viewAnnotation.location = coordinates;

SKAnimationSettings *animationSettings = [SKAnimationSettings animationSettings];
[self.skMapView addAnnotation:viewAnnotation withAnimationSettings:animationSettings];

Please help and tell how can i hide this info marker view. Thanks in advance.

Upvotes: 0

Views: 71

Answers (1)

user1722889
user1722889

Reputation:

Following method call will catch all click events on map.

-(void)mapView:(SKMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate 

Here I am hiding the info view.

Upvotes: 0

Related Questions