What does map.setMyLocationEnabled(true) really do

I am setting:

map.setMyLocationEnabled(true)

But I am wondering what this really does. What I know:

  1. I get a locate me button in the upper right corner of the map
  2. I get a blue icon on the map that represents my current location

Here is my concern. I am writing a location aware app but I am concerned about battery. Elsewhere in my app (via preferences) I set up a LocationManager and listen for location events so I can log them. But part of my preferences is the accuracy at which I get updates and the interval.

When I turn off my LocationManager:

locationManange.removeUpdates(LocationListener listener);

I expect to turn off location services for the entire app. Yet I still see the little GPS icon in my phones header bar indicating the app is getting location updates. I know that is coming from the fact that I set this on my map view:

map.setMyLocationEnabled(true);

I originally thought that if you did not listen for Location updates by setting up a LocationManager that set map.setMyLocationEnabled(true) would have no effect (ie no my location icon, or button). However that is not true.

Does that mean that by calling map.setMyLocationEnabled(true) google is setting up its own LocationManager with its own settings? I would really like to call map.setMyLocationEnabled(true), but have it use my settings for location updates not whatever google is doing under the hood. Is that possible? Did I miss something in the docs? I cannot find anything about the accuracy or interval that is setup on a LocationManager when I call map.setMyLocationEnabled(true).

Answers


Does that mean that by calling map.setMyLocationEnabled(true) google is setting up its own LocationManager with its own settings?

Not exactly. Maps V2 uses LocationClient by default.

I would really like to call map.setMyLocationEnabled(true), but have it use my settings for location updates not whatever google is doing under the hood. Is that possible?

You can use setLocationSource() to supply your own location data for use with the my-location layer. Here is a sample project demonstrating this.


Need Your Help

iOS 7 Back Button Pop Gesture

iphone ios objective-c uinavigationcontroller

In iOS 7 there's the new swipe to pop gesture: You swipe from left to right on the left side of your screen and the UINavigationController pops back to the previous UIViewController.

What is the difference between 'typedef' and 'using' in C++11?

c++ c++11 typedef using-declaration

I know that in C++11 we can now use using to write type alias, like typedefs: