Contents

MKOverlayRenderer

The shared infrastructure for drawing overlays on the map surface.

Declaration

class MKOverlayRenderer

Overview

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 the map view uses. Subclasses need to override the draw(_:zoomScale:in:) 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.

You can subclass MKOverlayRenderer to create overlays based on custom shapes, content, or drawing techniques. The only method subclasses need to override is the draw(_:zoomScale:in:) method. However, if your class contains content that may not be ready for drawing right away, you need to also override the canDraw(_: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 draw(_:zoomScale:in:) method needs to be safe to run from background threads and from multiple threads simultaneously.

Topics

Creating an overlay view

Attributes of the overlay

Converting points on the map

Drawing the overlay

Types

See Also

Shared behavior