how do I display the user location in a mapView while not running GPS to update the location (at all)? Will
mapView.userTrackingMode = kCLLocationAccuracyNearestTenMeters;
do the job or will GPS still burn battery in the background?
Thanks 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m going to attempt to answer your question as best as i can given the limited information.
The GPS has 3 main modes that go from low power to high power, low accuracy to high accuracy.
An
MKMapViewwill show a blue dot for the user location if you setshowsUserLocationtoYES. TheMKMapViewwill use all available location methods to find the users location as accurately as possible and keep updating it while this is set to YES.The tracking in
MKMapView, a mode which keeps the users location centred on screen, moves the visible map region as the user moves and is available in iOS5. you are given threeMKUserTrackingModes to choose from. From the docs:So setting it to
kCLLocationAccuracyNearestTenMetersisn’t going to work as it is not an available option in this context.Will showing the location burn battery in the background? It depends on what you mean by background. When the user taps the home button the
MKMapViewis forced to stop using the GPS by the system. While the app is running and the MKMapView is alive and has theshowsUserLocationproperty set toYESit will keep using any available method, including the GPS, to update the location. You have a couple of strategies to reduce this.1) presume that the user needs to see their location updated while the map is on screen. In which case keep
showsUserLocationset to YES until the map is moved off screen, or the device is locked, then set it toNO2) Presume the user only needs to see a static marker of their location from a particular point in time, like when the app is opened. In this case you need to make a
CLLocationManagerobject, ask it tostartUpdatingLocation, filter the delegate messages for the accuracy you want, and then turn off location updates (stopUpdatingLocation). You can then add anMKAnnotationto theMKMapViewto show the user their location.As you can see number 2 is more work, yet very power efficient. Number 1 is easy, but will use more battery while the map is visible. It is up to you to decide which behaviour the user expects and to implement your app accordingly.