1
votes

I'm building an iPhone app. There is a screen with a map (MKMapView) always showing. But to preserve battery, I don't want user location to be updated all the time, only automatically (every 15 minutes) and manually (onclick).

But, I also want to show this user location on the map. The problem is, if I showsUserLocation for my MapView, it automatically starts updating location, hence drains battery.

I tried activating the showsUserLocation option, saving the MKUserLocation, then deactivating the showsUserLocation then adding the saved MKUserLocation as an annotation by hand, but it actually shows a WARNING and reactivate the showsUserLocation option !

So I guess the last way is by hand:

I built a blue dot annotation myself but it doesn't have the glowing effect and the accuracy circle around. Do you have any idea how to do this? Or if there is any other way, please share.

Thanks !

3
I think you'd confuse the user if you have a pulsing blue dot that is used everywhere else for the current location, but dumbed it down to be accurate only once every 15 minutes. Also, you can set the desiredAccuracy of the location manager to only send you notifications when the location has changed significantly if you want to lower battery usage. - Craig
@Craig maybe,I guess that depends on the app ? I could update every 5 minutes, the fact is that keeping a map with showsUserLocation to YES is really draining battery. How could setting desiredAccuracy change this? To see significant changes, doesn't the GPS have to be ON, hence draining battery? Thanks - Noé Malzieu
I'm not quite sure how Apple achieve it, but they do state that asking for lower accuracy does save battery life. Perhaps they wait to see if the phone changes cell towers and then power up the GPS to get the actual location. You could put something else on the user's location, but the blue pulsing ball is what Apple and most apps mean for the live-tracking of user location. You'd be changing the meaning of the pulses if you used it for an out of date location. - Craig

3 Answers

2
votes

well you will have to go with your 'last way' -- MKAnnotationViews can easily be animated -- just treat it like any UIView :) there

see MKMapView current location showing as custom pins for how to mae custom Pins

2
votes

Just use native flag to enable this like so:

[mapView setShowsUserLocation:YES]
0
votes

If you want some help on the user location annotation stuff, check out how it's done in MapBox:

http://mapbox.com/mapbox-ios-sdk

In particular you want RMUserLocation. The whole SDK is open source.