The shared infrastructure used to draw overlays on the map surface.


@interface MKOverlayRenderer : NSObject


An overlay renderer draws 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. Subclasses are expected to override the drawMapRect:zoomScale:inContext: method to draw the contents of the overlay.

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

Subclassing Notes

You can subclass MKOverlayRenderer to create overlays based on custom shapes, content, or drawing techniques. The only method subclasses are expected to override is the drawMapRect:zoomScale:inContext: method. However, if your class contains content that may not be ready for drawing right away, you should also override the canDrawMapRect:zoomScale: method and use it to report when your class is ready and able to draw.

The map view may tile large overlays and distribute the rendering of each tile to separate threads. Therefore, the implementation of your drawMapRect:zoomScale:inContext: method must be safe to run from background threads and from multiple threads simultaneously.


Creating an Overlay View

- initWithOverlay:

Initializes and returns the overlay renderer and associates it with the specified overlay object.

Attributes of the Overlay


The overlay object containing the data for drawing.


The amount of transparency to apply to the overlay.


The scale factor used to draw the overlay’s content.

Converting Points on the Map

- pointForMapPoint:

Returns the point in the overlay renderer’s drawing area corresponding to the specified point on the map.

- mapPointForPoint:

Returns the point on the map that corresponds to the specified point in the overlay renderer’s drawing area.

- rectForMapRect:

Returns the rectangle in the overlay renderer’s drawing area corresponding to the specified rectangle on the map.

- mapRectForRect:

Returns the rectangle on the map that corresponds to the specified rectangle in the overlay renderer’s drawing area.

Drawing the Overlay

- canDrawMapRect:zoomScale:

Returns a Boolean value indicating whether the overlay view is ready to draw its content.

- drawMapRect:zoomScale:inContext:

Draws the overlay’s contents at the specified location on the map.

- setNeedsDisplay

Invalidates the entire contents of the overlay for all zoom scales.

- setNeedsDisplayInMapRect:

Invalidates the specified portion of the overlay at all zoom scales

- setNeedsDisplayInMapRect:zoomScale:

Invalidates the specified portion of the overlay but only at the specified zoom scale.



A scale factor being used in conjunction with a map.


Returns the width (in screen points) of roads on a map at the specified zoom level.


Inherits From

See Also

Annotations and Overlays


A user-friendly description of a location on the map.


An interface for associating your content with a specific map location.


The visual representation of one of your annotation objects.


An interface for associating content with a specific map region.

MapKit Annotations

Use these annotation objects as-is in your maps.

MapKit Overlays

Use these overlays as-is in your maps.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software