Search code examples
iosios5mkmapviewmkannotationcllocation

Show circle around selected location


As we have seen there is a circle around current location in iOS mkmapview. Is there any way to draw a similar circle in mkmapview for location other then current location?


Solution

  • If you look at the documentations for MKCircle: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKCircle_class/Reference/Reference.html and MKCircleView: http://developer.apple.com/library/iOS/documentation/MapKit/Reference/MKCircleView_class/Reference/Reference.html
    both of which are part of the MapKit API, you'll find tools for drawing circles! As mentioned at this link Circle around a point on an MKMapView there are no easy way to create animations for these circles, however the advantage is that they will provide you with a degree of accuracy for your coordinates on your map! The steps to creating the circles, one way, is here: Drawing a circle on mapkit
    Basically, create an MKCircle object using circleWithCenterCoordinate:radius: method and add it to your mapView (using addOverlay: method)
    Next, in the mapView delegate, implement mapView:viewForOverlay: method, create and setup MKCircleView instance there and return it.