ios getting my location regularly and setting button to get my location - Google Map not working

前端 未结 1 1813
旧巷少年郎
旧巷少年郎 2020-12-11 12:17

I am working on Google Map Module , using 1.9.0 Bundle, to find my location on regular basis , say 10 seconds and create a button to get my location button as one of mapview

相关标签:
1条回答
  • 2020-12-11 13:08

    Did your - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ get called?

    If not, you need to make sure your MapViewController implements the CLLocationDelegate. (Ex: @interface ViewController : UIViewController<CLLocationManagerDelegate> in your MapViewController.h file)

    You can try this working example from GitHub, or the code snippet from this Gist.

    Also, you should test it in your real device, otherwise you have to simulate a location in your XCode simulator (see image below, but it might not always work).

    enter image description here

    You have to add NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to your info.plist file (note: don't rename or change the extension of the info.plist file, the extension has to be .plist):

    enter image description here

    enter image description here

    0 讨论(0)
提交回复
热议问题