Circle of Uncertainty

Two objects

To annotate the MKMapView with a circle, we have to create two objects. See the Location Awareness Programming Guide.

  1. An Annotation, which adopts the MKAnnotation protocol and holds a CLLocationCoordinate2D (latitude and longitude). The Annotation must be created before its AnnotationView.
  2. An AnnotationView, derived from class MKAnnotation, which is derived from class UIView. The AnnotationView is created (or at least returned) by the mapView:viewForAnnotation: method of the MKMapViewDelegate.

Source code in

  1. main.m
  2. Class MapAppDelegate
  3. Class View
  4. Class Annotation
  5. Class AnnotationView
  6. Property list Map-Info.plist

Create the project

To create class View,

File → New File…
Objective-C class
Subclass of UIView
File Name: View.m
✓ Also create "View.h"

Create class Annotation as a subclass of NSObject, and class AnnotationView as a subclass of UIView. Thenedit AnnotationView.h and change it to a subclass of MKAnnotationView.

Add the Core Location and Map Kit frameworks:
Project → Edit Active Target "Map" → General → Linked Libraries
You should already have three frameworks: Foundation, UIKit, and Core Graphics. Press the plus sign and add CoreLocation.framework and MapKit.framework.

Allow the app to run only on a device that has the required device capabilities. Add a new property to the file Map-Info.plist in the Resources folder of the project. Display the file in the lower right pane of Xcode. Click on the plus sign, scroll down to Required device capabilities, and select it. Then click on the triangle to make it point down, and add the item location-services.