Ankur
Ankur

Reputation: 1

Add single tap recogniser is not working in GMSMapview

I am using GMSMapview and when I am implimenting single tap guesture on map then it is not working. how can I do this?

tapRec = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(mapDidTap:)];
tapRec.delegate = self;
tapRec.numberOfTapsRequired = 1;
[mapView2 addGestureRecognizer: tapRec];

and

 -(void)mapDidTap:(UITapGestureRecognizer *)gestureRecognizer 
{
[mapView2 removeGestureRecognizer:tapRec];
_filterView.hidden = YES;
}

Upvotes: 0

Views: 449

Answers (2)

Rohit Arora
Rohit Arora

Reputation: 169

You don't need to add tap gesture. GMSMapView provides its own method to detect the tap on particular latitude/longitude.

func mapView(mapView: GMSMapView, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
    //Coordinates where user has tapped
    print(coordinate)
}

Upvotes: 2

Sujit
Sujit

Reputation: 658

GMSMapView having delegate method. Integrate this method.

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

Upvotes: 1

Related Questions