mapbox / mapbox-gl-native-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and OpenGL
https://www.mapbox.com/mobile/
Other
210 stars 122 forks source link

Howto get the front-most feature, the user tapped on #636

Open georgbachmann opened 2 years ago

georgbachmann commented 2 years ago

I'd like to know if there is a way to best detect a users tap on a label? The new iOS15 Maps app allows a tap on e.g. a cities name and then shows informations about that city. I am now wondering if something similar can be done with mapbox?

I know that there is a mapView.visibleFeatures(in: myRect) function that can somehow help here. So I can convert my finger location to a rect and then get all features there. BUT... my city e.g. might have a label that is let's say 200 px wide. So I would need to have a quite large rect to find the point of my city label.

Is there no way to ask the map what the frontmost element was when I tapped? So that when I tap on the far end of the label, I still get that ONE feature?