0

I have the location manager updating the current location and I move a pin on my map reflecting the location. However, when the location manager-desired accuracy is at 'best' and you are moving, the updates are almost continuous, so the code when a new location is received is being run constantly. This prevents the user from touching the screen and doing other functions, like zooming, moving changing to another tab, etc. How can I separate these 2 tasks, i.e something whereby the lcoationmanger did update to location method should be running on a parallel thread or something, so that the touches can happen regardless?

Thanks for any inputs!

user542584
  • 2,651
  • 2
  • 25
  • 29

1 Answers1

1

I don't know if that suite your needs, but it may be better in that case not to use CLLocationManager's delegate, but instead use a scheduler to query it yourself every few seconds.

hungary54
  • 767
  • 8
  • 11
  • you mean by using a scheduler to start and stop location manager to get the location? I think that would be an overhead too? – user542584 Nov 14 '11 at 07:39
  • No. I meant to access the CLLocationManager and update your map from your function (the one that is called by the scheduler), and not from your CLLocationManager's delegate which I understand is called too often. – hungary54 Nov 14 '11 at 08:15
  • Hi, but I need the current location of the phone in latitude and longitude, which I thought was possible only from CLlocationmanagers delegate - how else can I get it from my own function? – user542584 Nov 14 '11 at 08:53
  • If you can access your CLLocationManager instance, then you can simply get the lat/long by calling locationManager.location.coordinate.longitude. Keep in mind that it is recommended to create only one instance of CLLocationManager, so in order to access your instance from your function you may need to have it as a singleton. You can check this tutorial about [CLLocationManager as a single instance](http://www.speedyapi.com/index.php/posts/88-cllocationmanager-instance) – hungary54 Nov 14 '11 at 09:23
  • Thanks for that suggestion, I shall check it out. – user542584 Nov 14 '11 at 17:34