Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

19. Core Location and MapKit > Recipe: User Location Annotations

Recipe: User Location Annotations

Recipe 19-6 provided a way to visually track a location event as it focused over time. Recipe 19-7 kicks this idea up a notch to track a device as it moves over time. Instead of sampling locations over time and picking the best result, it employs a far easier approach while achieving similar results. It hands over all responsibility for user location to the map view and its userLocation property, using a timer to check in occasionally and update.

As mentioned in the discussion for Recipe 19-6, enabling the showsUserLocation property automatically tasks Core Location to track the device. Recipe 19-7 leverages this capability by checking that location once every few seconds. It updates the map view to reflect that location, keeping the map centered on the user and adding a custom annotation to the user pin to display the current coordinates.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial