mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

POI detection by tapping on the mapView

Open hastiranjkesh opened this issue 7 years ago • 1 comments

I'm using a map view in my iOS application that its type is NavigationMapView. I need to detect when the user taps on the map view in order to display POI information. I defined a UITapGestureRecognizer and added it to the map view. On another hand, my view controller confirms NavigationMapViewDelegate protocol and I implemented below delegate method of the protocol:

func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) 

but the problem is when I added a tap gesture recognizer on the map view, the delegate method won't call anymore. Is there any other way to detect POI?

**Mapbox Navigation SDK version: v0.27.0 **

hastiranjkesh avatar Feb 13 '19 12:02 hastiranjkesh

I read Mapbox document ( https://docs.mapbox.com/ios/api/maps/4.7.1/gesture-recognizers.html ) and found that I need to add below delegate method if I want my own gesture recognizer to work simultaneously with built-in gesture recognizers:

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(mapViewDidTap))
tapGesture.delegate = self
mapView.addGestureRecognizer(tapGesture)

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return true
}

Mapbox document says: "The gesture recognizers that you add will take priority over the built-in gesture recognizer. You can also set up your own gesture recognizer to work simultaneously with built-in gesture recognizers by using -gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:, allowing you to enhance already existing gesture recognizers."

hastiranjkesh avatar Feb 14 '19 12:02 hastiranjkesh