Class

MKOverlay​View

The MKOverlay​View class defines the basic behavior associated with all overlay views. An overlay view provides the visual representation of an overlay object—that is, an object that conforms to the MKOverlay protocol. This class defines the drawing infrastructure used by the map view but does not do any actual drawing. Subclasses are expected to override the draw​Map​Rect:​zoom​Scale:​in​Context:​ method in order to draw the contents of the overlay view.

Overview

The Map Kit framework provides several concrete instances of overlay views. Specifically, it provides overlay views for each of the concrete overlay objects. You can use one of these existing overlay views or define your own subclass if you want to draw the overlay contents differently.

In iOS 7 and later, use the MKOverlay​Renderer class to display overlays instead.

Subclassing Notes

You can subclass MKOverlay​View to create overlays based on custom shapes and content. The only method subclasses are expected to override is the draw​Map​Rect:​zoom​Scale:​in​Context:​ method. However, if your class contains content that may not be ready for drawing right away, you should also override the can​Draw​Map​Rect:​zoom​Scale:​ method and use it to report when your class is ready and able to draw.

The implementation of your draw​Map​Rect:​zoom​Scale:​in​Context:​ method must be safe to run from multiple threads simultaneously. To improve performance, the map view may tile overlays that are large enough and distribute the rendering of each tile to separate threads.