Closed makinggainz closed 5 years ago
-[MGLAnnotationView setSelected:animated:]
gets called as soon as the user taps on the annotation. Your MGLAnnotationView subclass could override this method, performing some animation when setSelected:
and animated:
are both true. The method gets called by a tap gesture recognizer built into MGLMapView. It’s essentially a touch-up-inside recognizer, but that means touch-up-inside the map view, not necessarily inside the annotation view.
Thanks, @1ec5, is it possible for it to be called as soon as the user presses? Or is there another method which can be used for this? I looked through the docs you sent and could not find anything.
Because that method runs only after letting go...
A gesture recognizer would probably be the way to go. (If you don’t want the annotation to move, then you shouldn’t set that draggable
property.) Can you share what you’ve tried so far? It’s possible that your gesture recognizer is conflicting with the map view’s built-in tap gesture recognizer. There’s some documentation about avoiding these conflicts, though it pertains to gesture recognizers installed on the map view rather than an individual annotation view.
I successfully solved my problem using the following answer here: https://github.com/mapbox/mapbox-navigation-ios/issues/1975
/cc @jmkiley re previous example discussion
mapbox-gl-js version: latest as of writing
Question
How to give an MGLAnnotation feedback when tapped?
Links to related documentation:
When an annotation is tapped I would like for it to have some sort of feedback. (like a depression (width and height contract as seen on snapchat)).
I have tried doing this through gesture recognizers but I find that they dont seem to work as intended and also dont allow the didselect to run. So now I am trying to make it work using [this example on mapboxes website][1] where an annotation can be dragged.
I only have 2 issues with this. 1: it seems to animate in a delayed fashion and 2 how can I prevent the annotation from being movable.