1

I want to handle 2 separate events: 1. User drags the map. 2. Map location changed (due to location change).

So far region[Did/Will]ChangeAnimated is called on those 2 events. How can I distinguish between these events?

Jon O
  • 6,532
  • 1
  • 46
  • 57
Idan Moshe
  • 1,675
  • 4
  • 28
  • 65
  • I saw it, thats not indicating if map dragged or changed due to location change, what I asked is different. – Idan Moshe Feb 10 '14 at 20:15
  • "map location changed due to location change" - do you mean when the map view automatically changed its visible region in response to tracking the user's current location? – Mike Mertsock Feb 10 '14 at 22:31
  • @IdanMoshe actually if you look at the answer below the accepted one you'll see that they use gesture recognizers to do exactly what you're trying to do. – Gad Feb 11 '14 at 05:18
  • @esker yes. The gesture recognizer covers half of my question, in the other half I want to know if '2' happen not because of '1'. – Idan Moshe Feb 11 '14 at 05:48
  • This is not a duplicate question. – Mike Mertsock Feb 11 '14 at 12:38

1 Answers1

2

There are two distinct methods you can implement in your map view delegate to respond to these two events:

When the user drags the map around (or rotates it, or pinches/taps to zoom in, etc.): mapView:regionDidChangeAnimated:

When the map view is tracking the user's location and updates the view as the user's location changes: mapView:didUpdateUserLocation:

Try implementing both of these methods with some NSLog statements and mess around with the map view to get an idea of when and how frequently these methods are called.

Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75