I’m using MapKit to display the user’s location relative to pins around them. I’d like to be able to mimic the functionality that Maps provides via the crosshair button in the lower left-hand corner of the screen. I’m already aware that MapKit provides a CLLocation object with the user’s location via MKUserLocation, I just wanted to seek advice on how I should keep focus on that location. My initial inclination was to use an NSTimer to center the map on that coordinate every 500ms or so.
Is there a better way to do this? Is there something built in to MapKit that I’m missing that will accomplish this?
Thanks so much,
Brendan
I think that I would actually use the CoreLocation
CLLocationManagerand use its delegate methodlocationManager:didUpdateToLocation:fromLocation:.This way, you don’t have the overhead of an
NSTimer, and it only updates when there’s a new location available.You can pull the longitude and latitude from the
CLLocationobject sent to thelocationManager:didUpdateToLocation:fromLocation:method and pass it to the map view.