0

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;
}
Ankur
  • 1
  • 4

2 Answers2

2

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)
}
Rohit Arora
  • 169
  • 1
  • 5
1

GMSMapView having delegate method. Integrate this method.

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
Sujit
  • 610
  • 7
  • 26