I have a collection of addresses, and I needed to convert them into co-ordinates. What I did was to divide the collection into chunks of maximum 40 contacts(you may go up to 50, but not beyond that in a minute). So a group with over 40 contacts had to have a delay in between so that all the addresses would be processed and converted into co-ordinates before the mapview loads.
I need to load the mapview based on user requirements. In my case, the mapview could be loaded again and gain, irrespective of the contacts list in the group and irrespective of the time factor. If the user intends to load the mapview and reload it again under 1 minute I needed to develop a logic for that. For that I decided to save the state of the mapview, if the user decided to reload the same group of addresses under 1 minute.
But if the user decided to load another group of contacts, then I had to rethink my logic, based on the group of contacts to be loaded. So I had to keep track of which group was to be loaded(previous one or a new one), whether the group had number of contacts over 40 or not.
Another important factor I had to take care of was the time. For that, I had a static NSDate
variable which always kept track of the "time" when the CLGeocoder
worked the last time, and if the current time(when the CLGeocoder
is about to use) has not got a difference of 1 minute, then I had to delay loading the map.
This is what I have done to implement mapView using co-ordinates from CLGeocoder
. I am sure the logic can be optimized to a great extent and output would be faster.
Would appreciate if someone comes up with a better implementation.