2

I need to keep tracking user's current visible region in map view, based on user's current visible region, I will make a async web service call. So I make the async web service call in the mapView(_:regionDidChangeAnimated:) function. However this function will be called several times at the beginning when the Mapkit try to locate user's current location. So this is what I want to achieve:

  1. When the map view is zooming into user's current location with a span: MKCoordinateSpan(latitudeDelta: 0.25, longitudeDelta: 0.25) at the beginning, I don't want to make any async web service call.
  2. After the map view complete locating user's current location (after completing the zoom in), I start tracking user's current visible region. When the user move around the map, I could make the web service call.

So, is there any method, I can avoid web service call when the map view is in zooming period?

PoppinDouble
  • 315
  • 2
  • 12
  • Did you ever figure this out? – rachiebytes Dec 01 '15 at 17:17
  • HI: I don't think it is possible to avoid it, so at the end, i still used the async call, because the result of the web service is different all the time (the visible region is keep changing). so i used a local data structure, (you can use array or any data structure you like) to store the web service result, and every time when the Json file return, remember to clean the local data structure, when the visible region become stable, the local data structure should store your last web service call, and then dispatch back to the main queue, hope this will help you. – PoppinDouble Dec 01 '15 at 20:35
  • Cool, it did, thank you! – rachiebytes Dec 01 '15 at 21:46

0 Answers0