How to detect MapKit Map panning/scrolling ended

Hello,

I'm trying to figure out how to detect when user stops scrolling (panning) the map.

The problem:

  • I have a MapAnnotation that I want to always keep in the centre, even is user is panning/scrolling the map. When map is open first time, the original annotation location is user's current location. I request the name of the location to display it on top of the annotation.
  • when user moves the map around, I want to track when he stop this action and select a location in the centre of map's new region and display the a location's name on top of the annotation
  • I can't use .onChange() because region centre changes constantly as user moves the map, because it causes to many requests for location's name
  • DragGesture .onEnded() is never called, so I have no idea when customer stops moving the map

So my question is - how to detect in this case when customer stopped moving the map?

Have anyone faced the same problem? Any ideas how to solve it?

Hey @AndySh did you ever get this working? I'm facing a similar problem, thanks!

Use

.onMapCameraChange(frequency: .onEnd)

How to detect MapKit Map panning/scrolling ended
 
 
Q