0

For the mapView, I create it by self.view.addSubview(mapView!), so I guess that's why I can't override the touchesBegan function to detect the touch point. There is a function called didLongPressAtCoordinate in mapView delegate, but it only contains coordinates and mapView as argument.

func mapView(mapView: GMSMapView, didLongPressAtCoordinate coordinate: CLLocationCoordinate2D) {

}

Any suggestions?

Thanks.

Pak Ho Cheung
  • 1,382
  • 6
  • 22
  • 52

1 Answers1

0

Please try using UITapGestureRecognizer.

For the implementation, you can check the solution given in this SO post - UIScrollView touchesBegan.

Aside from that, explanation and sample code given in this blog - How to perform action when user taps on map using MapKit, Swift might also help.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22
  • Hi. Thank you for your help. But still doesn't work. I created a scroll view and add the MapView in like this self.view.addSubview(mapViewTouchView) mapViewTouchView.addSubview(mapView!). I am thinking is it because once the view detect the long press, the didLongPressAtCoordinate function will get called first – Pak Ho Cheung Aug 15 '16 at 06:44