Search code examples
iosswiftgoogle-mapsgoogle-maps-sdk-ios

Where does GMSMapView get its location data when isMyLocationEnabled is set to true?


I'm using the Google Maps iOS SDK to display a blue dot for my current location. I instantiate the map and set the flag to true via:

self.mapView.isMyLocationEnabled = true

Doing this shows the blue dot for my current location, but I cannot find any information about how often this data is updated. I'm concerned about battery usage while receiving location updates with this option.

  • Does the Google Maps SDK use its own CLLocationManager?
  • If so, what parameters does it use? Does it update the location continually?
  • What location accuracy does it use?
  • How does it handle the view going off screen?

Solution

  • What a coincidence, I have had the same questions recently and nothing could found in the Google documentation or somewhere.

    So here is my thoughts and observations on the matter, you might find something useful

    1. There is no way to get user's GPS location except using iOS CoreLocation, so I believe they use it as we do
    2. Based on how accurate it shows user's location on the map, I suspect Google map uses accuracy about 10 meters if not the best. Actual accuracy you can try to get from myLocation property that is CLLocation instance. I didn't try it. And probably It updates user location continually, however it doesn't keep your application in background, even if you have 'always' authorization.
    3. It uses user's location even when is off the screen, I looked at the energy bar, while my location manager was off and it fills corresponding cells for background, of course
      SDK might decrease accuracy, but I am not sure if subclass of UIView can even detect if it is shown or hidden. The only way I found, was to change flag to false

    self.mapView.isMyLocationEnabled = false

    Hope it helps, in case you'll find something to share regarding the question, please get back.