6
votes


I am new to MKMapView. I implemented a mapView which is looking good. But i was planning to add points or custom image as point in MapView. I can implement it with the help of MKAnnotation, but when i read MKOverlay it was mentioned that Overlays are also annotations. So whats the difference between these two??

Thanks in advance,
aby

2

2 Answers

9
votes

In a nutshell, MKAnnotation is based on a point (x,y). MKOverlay is based on an area, bounded by a rectangle.

7
votes

An MKAnnotation is simply a point on the map, often represented with a red pin icon (you'll see these if you search for a location in Apple's Maps app on iOS), whereas an MKOverlay is another layer over the map to display extra information. A good example of this could be the traffic overlay displayed on the map in US regions to indicate the current level of traffic.

You'd want to use an MKAnnotation in situations where you need to show the user a specific point on a map, but if you want to display more information to them over a larger area, go with an MKOverlay.

Apple uses an MKOverlay to display shipping routes for boats in their WWDC video on the topic (Session 127 – Customizing Maps with Overlays). That would be a good place to learn the full difference between the two, and how to use overlays correctly.