I'm implementing a map feature in my app where I allow the user to set their current location by panning around.
All this time, I want to have an MKAnnotation
in the centerCoordinate
. So what I want to do is keep track of when the map's centerCoordinate changes and change the annotation's coordinate correctly. The behaviour would be similar to that of Uber, Hailo and others.
I tried a time based implementation where every 0.00001s the centerCoordinate
would be checked and the annotation would also be moved. But if the map isn't flicked gently, the annotation jumps from one place to another which doesn't make for a good UI.
Another implementation I tried is by way of gesture recognisers and the delegate methods of MKMapView
(regionDidChange
/regionWillChange
). This, again, makes for a very abrupt transition.
Can anyone please advise me on how to do this better?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…